ClassFileWriterContext(String name, String superClassName, Class<T> type, String[] interfaceNames) { this.name = name; this.type = type; //FIXME Once we get rid of the old ClassFile stuff we should make the real names look like this //to start with name = ClassFileWriterContext.jvmClassName(name); superClassName = ClassFileWriterContext.jvmClassName(superClassName); for (int i = 0 ; i < interfaceNames.length ; i++) interfaceNames[i] = ClassFileWriterContext.jvmClassName(interfaceNames[i]); fileWriter = new ClassFileWriter(ClassFile.JAVA_4, 0); poolWriter = fileWriter.getConstPool(); thisClass = poolWriter.addClassInfo(name); superClass = poolWriter.addClassInfo(superClassName); interfaces = poolWriter.addClassInfo(interfaceNames); //Add default constructor mw = fileWriter.getMethodWriter(); mw.begin(Modifier.PUBLIC, MethodInfo.nameInit, "()V", null, null); mw.add(Opcode.ALOAD_0); mw.add(Opcode.INVOKESPECIAL); int signature = poolWriter.addNameAndTypeInfo(MethodInfo.nameInit, "()V"); mw.add16(poolWriter.addMethodrefInfo(superClass, signature)); mw.add(Opcode.RETURN); mw.codeEnd(1, 1); mw.end(null, null); }
ClassFileWriterContext(String name, String superClassName, Class<T> type, String[] interfaceNames) { this.name = name; this.type = type; //FIXME Once we get rid of the old ClassFile stuff we should make the real names look like this //to start with name = ClassFileWriterContext.jvmClassName(name); superClassName = ClassFileWriterContext.jvmClassName(superClassName); for (int i = 0 ; i < interfaceNames.length ; i++) interfaceNames[i] = ClassFileWriterContext.jvmClassName(interfaceNames[i]); fileWriter = new ClassFileWriter(ClassFile.JAVA_4, 0); poolWriter = fileWriter.getConstPool(); thisClass = poolWriter.addClassInfo(name); superClass = poolWriter.addClassInfo(superClassName); interfaces = poolWriter.addClassInfo(interfaceNames); //Add default constructor mw = fileWriter.getMethodWriter(); mw.begin(Modifier.PUBLIC, MethodInfo.nameInit, "()V", null, null); mw.add(Opcode.ALOAD_0); mw.add(Opcode.INVOKESPECIAL); int signature = poolWriter.addNameAndTypeInfo(MethodInfo.nameInit, "()V"); mw.add16(poolWriter.addMethodrefInfo(superClass, signature)); mw.add(Opcode.RETURN); mw.codeEnd(1, 1); mw.end(null, null); }
/** * Starts Adding a new method. * * @param accessFlags access flags. * @param name the method name. * @param descriptor the method signature. * @param exceptions throws clause. It may be null. * The class names must be the JVM-internal * representations like <code>java/lang/Exception</code>. * @param aw attributes to the <code>Method_info</code>. */ public void begin(int accessFlags, String name, String descriptor, String[] exceptions, AttributeWriter aw) { int nameIndex = constPool.addUtf8Info(name); int descIndex = constPool.addUtf8Info(descriptor); int[] intfs; if (exceptions == null) intfs = null; else intfs = constPool.addClassInfo(exceptions); begin(accessFlags, nameIndex, descIndex, intfs, aw); }
/** * Starts Adding a new method. * * @param accessFlags access flags. * @param name the method name. * @param descriptor the method signature. * @param exceptions throws clause. It may be null. * The class names must be the JVM-internal * representations like <code>java/lang/Exception</code>. * @param aw attributes to the <code>Method_info</code>. */ public void begin(int accessFlags, String name, String descriptor, String[] exceptions, AttributeWriter aw) { int nameIndex = constPool.addUtf8Info(name); int descIndex = constPool.addUtf8Info(descriptor); int[] intfs; if (exceptions == null) intfs = null; else intfs = constPool.addClassInfo(exceptions); begin(accessFlags, nameIndex, descIndex, intfs, aw); }
/** * Starts Adding a new method. * * @param accessFlags access flags. * @param name the method name. * @param descriptor the method signature. * @param exceptions throws clause. It may be null. * The class names must be the JVM-internal * representations like <code>java/lang/Exception</code>. * @param aw attributes to the <code>Method_info</code>. */ public void begin(int accessFlags, String name, String descriptor, String[] exceptions, AttributeWriter aw) { int nameIndex = constPool.addUtf8Info(name); int descIndex = constPool.addUtf8Info(descriptor); int[] intfs; if (exceptions == null) intfs = null; else intfs = constPool.addClassInfo(exceptions); begin(accessFlags, nameIndex, descIndex, intfs, aw); }
/** * Starts Adding a new method. * * @param accessFlags access flags. * @param name the method name. * @param descriptor the method signature. * @param exceptions throws clause. It may be null. * The class names must be the JVM-internal * representations like <code>java/lang/Exception</code>. * @param aw attributes to the <code>Method_info</code>. */ public void begin(int accessFlags, String name, String descriptor, String[] exceptions, AttributeWriter aw) { int nameIndex = constPool.addUtf8Info(name); int descIndex = constPool.addUtf8Info(descriptor); int[] intfs; if (exceptions == null) intfs = null; else intfs = constPool.addClassInfo(exceptions); begin(accessFlags, nameIndex, descIndex, intfs, aw); }
void beginMethod(int accessFlags, String name, String descriptor, String[] exceptions) { mw.begin(Modifier.PUBLIC, name, descriptor, exceptions, null); }
void beginMethod(int accessFlags, String name, String descriptor, String[] exceptions) { mw.begin(Modifier.PUBLIC, name, descriptor, exceptions, null); }
/** * Starts Adding a new method. * * @param accessFlags access flags. * @param name the method name. * @param descriptor the method signature. * @param exceptions throws clause. It may be null. * The class names must be the JVM-internal * representations like <code>java/lang/Exception</code>. * @param aw attributes to the <code>Method_info</code>. */ public void begin(int accessFlags, String name, String descriptor, String[] exceptions, AttributeWriter aw) { int nameIndex = constPool.addUtf8Info(name); int descIndex = constPool.addUtf8Info(descriptor); int[] intfs; if (exceptions == null) intfs = null; else intfs = constPool.addClassInfo(exceptions); begin(accessFlags, nameIndex, descIndex, intfs, aw); }
/** * Starts Adding a new method. * * @param accessFlags access flags. * @param name the method name. * @param descriptor the method signature. * @param exceptions throws clause. It may be null. * The class names must be the JVM-internal * representations like <code>java/lang/Exception</code>. * @param aw attributes to the <code>Method_info</code>. */ public void begin(int accessFlags, String name, String descriptor, String[] exceptions, AttributeWriter aw) { int nameIndex = constPool.addUtf8Info(name); int descIndex = constPool.addUtf8Info(descriptor); int[] intfs; if (exceptions == null) intfs = null; else intfs = constPool.addClassInfo(exceptions); begin(accessFlags, nameIndex, descIndex, intfs, aw); }