public org.apache.bcel.generic.Type toJCType() { return new org.apache.bcel.generic.ObjectType(NODE_ITERATOR); }
/** * Convenience constructor for reference array type, e.g. Object[] * * @param class_name complete name of class (java.lang.String, e.g.) */ public ArrayType(String class_name, int dimensions) { this(new ObjectType(class_name), dimensions); }
/** * @since 6.0 */ public static ObjectType getInstance(final String class_name) { return new ObjectType(class_name); }
ObjectType[] objectArray = new ObjectType[10]; // Or as many as required. for (int i = 0; i < objectArray.length; i++) { objectArray[i] = new ObjectType(); // Or whatever constructor you need. } // Then access an individual object like this... ObjectType obj = objectArray[4]; // Or... objectArray[5].someMethod();
... il.append(_factory.createInvoke("A$B$X", "<init>", Type.VOID, new Type[] { new ObjectType("A$B") }, Constants.INVOKESPECIAL));
public org.apache.bcel.generic.Type toJCType() { return new org.apache.bcel.generic.ObjectType(NODE_ITERATOR); }
... _cg = new ClassGen("A$B$X", "java.lang.Object", "A.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); ... il.append(_factory.createFieldAccess("A$B$X", "this$1", new ObjectType("A$B"), Constants.PUTFIELD));
/** * Since InvokeDynamic doesn't refer to a reference type, just return java.lang.Object, * as that is the only type we can say for sure the reference will be. * * @param cpg * the ConstantPoolGen used to create the instruction * @return an ObjectType for java.lang.Object * @since 6.1 */ @Override public ReferenceType getReferenceType(final ConstantPoolGen cpg) { return new ObjectType(Object.class.getName()); } }
/** * Set (optional) initial value of field, otherwise it will be set to null/0/false * by the JVM automatically. */ public void setInitValue(String str) { checkType(new ObjectType("java.lang.String")); if(str != null) value = str; }
/** @return type of the referenced class/interface */ public ObjectType getClassType(ConstantPoolGen cpg) { return new ObjectType(getClassName(cpg)); }
public NEW createNew(String s) { return createNew(new ObjectType(s)); }
/** * @param encodedFieldName the encoded field name */ protected void addField(String encodedFieldName) { if (!internalFieldRepresentingClasses.contains(encodedFieldName)) { //System.out.println("method."+method.getName()+".addingfield[" // + _encodedFieldName + "]"); FieldGen field = new FieldGen(Constants.ACC_STATIC, new ObjectType("java.lang.Class"), encodedFieldName, constantsPool); classGen.addField(field.getField()); internalFieldRepresentingClasses.add(encodedFieldName); } }
/** * Add method * <pre> * private transient org.codehaus.jremoting.client.StubHelper stubHelper; * </pre> */ protected void createFields() { FieldGen field; field = new FieldGen(Constants.ACC_PRIVATE | Constants.ACC_TRANSIENT, new ObjectType("org.codehaus.jremoting.client.StubHelper"), "stubHelper", constantsPool); classGen.addField(field.getField()); }
public AnnotationEntryGen createSimpleVisibleAnnotation(final ConstantPoolGen cp) { final SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_INT, cp, 4); final ElementValuePairGen nvGen = new ElementValuePairGen("id", evg, cp); final ObjectType t = new ObjectType("SimpleAnnotation"); final List<ElementValuePairGen> elements = new ArrayList<>(); elements.add(nvGen); final AnnotationEntryGen a = new AnnotationEntryGen(t, elements, true, cp); return a; }
public AnnotationEntryGen createSimpleInvisibleAnnotation(final ConstantPoolGen cp) { final SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_INT, cp, 4); final ElementValuePairGen nvGen = new ElementValuePairGen("id", evg, cp); final ObjectType t = new ObjectType("SimpleAnnotation"); final List<ElementValuePairGen> elements = new ArrayList<>(); elements.add(nvGen); final AnnotationEntryGen a = new AnnotationEntryGen(t, elements, false, cp); return a; } }
public AnnotationEntryGen createFruitAnnotation(final ConstantPoolGen cp, final String aFruit) { final SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.STRING, cp, aFruit); final ElementValuePairGen nvGen = new ElementValuePairGen("fruit", evg, cp); final ObjectType t = new ObjectType("SimpleStringAnnotation"); final List<ElementValuePairGen> elements = new ArrayList<>(); elements.add(nvGen); return new AnnotationEntryGen(t, elements, true, cp); }
public AnnotationEntryGen createFruitAnnotationEntry(final ConstantPoolGen cp, final String aFruit, final boolean visibility) { final SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.STRING, cp, aFruit); final ElementValuePairGen nvGen = new ElementValuePairGen("fruit", evg, cp); final ObjectType t = new ObjectType("SimpleStringAnnotation"); final List<ElementValuePairGen> elements = new ArrayList<>(); elements.add(nvGen); return new AnnotationEntryGen(t, elements, visibility, cp); } }
public AnnotationEntryGen createCombinedAnnotation(final ConstantPoolGen cp) { // Create an annotation instance final AnnotationEntryGen a = createSimpleVisibleAnnotation(cp); final ArrayElementValueGen array = new ArrayElementValueGen(cp); array.addElement(new AnnotationElementValueGen(a, cp)); final ElementValuePairGen nvp = new ElementValuePairGen("value", array, cp); final List<ElementValuePairGen> elements = new ArrayList<>(); elements.add(nvp); return new AnnotationEntryGen(new ObjectType("CombinedAnnotation"), elements, true, cp); }
/** * @param il the instruction list * @param msg the message */ protected void createTestMethod(InstructionList il, String msg) { il.append(factory.createFieldAccess("java.lang.System", "out", new ObjectType("java.io.PrintStream"), Constants.GETSTATIC)); il.append(new PUSH(constantsPool, msg)); il.append(factory.createInvoke("java.io.PrintStream", "println", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKEVIRTUAL)); }
public void testCreateClassElementValue() throws Exception { final ClassGen cg = createClassGen("HelloWorld"); final ConstantPoolGen cp = cg.getConstantPool(); final ObjectType classType = new ObjectType("java.lang.Integer"); final ClassElementValueGen evg = new ClassElementValueGen(classType, cp); assertTrue("Unexpected value for contained class: '" + evg.getClassString() + "'", evg.getClassString().contains("Integer")); checkSerialize(evg, cp); }