@Override protected void setUp() throws Exception { super.setUp(); world = new BcelWorld(); javaLangClass = (ReferenceType) world.resolve(UnresolvedType.forName("java/lang/Class")); javaLangObject = (ReferenceType) world.resolve(UnresolvedType.OBJECT); extendsClass = new BoundedReferenceType(javaLangClass, true, world); superClass = new BoundedReferenceType(javaLangClass, false, world); extendsWithExtras = new BoundedReferenceType( javaLangClass, true, world, new ReferenceType[] { (ReferenceType) world.resolve(UnresolvedType.forName("java/util/List")) }); }
public void testCanBeParameterizedRegularMethod() { BcelWorld world = new BcelWorld(); ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java/lang/Class")); ResolvedMember[] methods = javaLangClass.getDeclaredMethods(); ResolvedMember getAnnotations = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals("getAnnotations")) { getAnnotations = methods[i]; break; } } if (getAnnotations != null) { // so can run on non-Java 5 // System.out.println("got it"); assertFalse(getAnnotations.canBeParameterized()); } }
public void testCanBeParameterizedMethodInGenericType() { BcelWorld world = new BcelWorld(); world.setBehaveInJava5Way(true); ResolvedType javaUtilList = world.resolve(UnresolvedType.forName("java.util.List")); javaUtilList = javaUtilList.getGenericType(); if (javaUtilList == null) return; // for < 1.5 ResolvedMember[] methods = javaUtilList.getDeclaredMethods(); ResolvedMember add = null; for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals("add")) { add = methods[i]; break; } } if (add != null) { // so can run on non-Java 5 // System.out.println("got it"); assertTrue(add.canBeParameterized()); } }