final Attribute[] attributes = getAttributePrototypes(); firstField = null; lastField = null; attributes, (hasFrames ? ClassReader.EXPAND_FRAMES : 0) | ClassReader.EXPAND_ASM_INSNS); return toByteArray();
ClassLoader classLoader = getClassLoader(); Class<?> class1; try {
/** * Adds a handle to the constant pool of the class being build. Does nothing if the constant pool * already contains a similar item. <i>This method is intended for {@link Attribute} sub classes, * and is normally not needed by class generators or adapters.</i> * * @param tag the kind of this handle. Must be {@link Opcodes#H_GETFIELD}, {@link * Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link * Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}. * @param owner the internal name of the field or method owner class. * @param name the name of the field or method. * @param descriptor the descriptor of the field or method. * @return the index of a new or already existing method type reference item. * @deprecated this method is superseded by {@link #newHandle(int, String, String, String, * boolean)}. */ @Deprecated public int newHandle( final int tag, final String owner, final String name, final String descriptor) { return newHandle(tag, owner, name, descriptor, tag == Opcodes.H_INVOKEINTERFACE); }
/** * Returns raw bytecode. */ protected byte[] toByteArray() { assertProxyIsCreated(); return destClassWriter.toByteArray(); }
/** * Adds a merged type in the type table of this symbol table. Does nothing if the type table * already contains a similar type. * * @param typeTableIndex1 a {@link Symbol#TYPE_TAG} type, specified by its index in the type * table. * @param typeTableIndex2 another {@link Symbol#TYPE_TAG} type, specified by its index in the type * table. * @return the index of a new or already existing {@link Symbol#TYPE_TAG} type Symbol, * corresponding to the common super class of the given types. */ int addMergedType(final int typeTableIndex1, final int typeTableIndex2) { // TODO sort the arguments? The merge result should be independent of their order. long data = typeTableIndex1 | (((long) typeTableIndex2) << 32); int hashCode = hash(Symbol.MERGED_TYPE_TAG, typeTableIndex1 + typeTableIndex2); Entry entry = get(hashCode); while (entry != null) { if (entry.tag == Symbol.MERGED_TYPE_TAG && entry.hashCode == hashCode && entry.data == data) { return entry.info; } entry = entry.next; } String type1 = typeTable[typeTableIndex1].value; String type2 = typeTable[typeTableIndex2].value; int commonSuperTypeIndex = addType(classWriter.getCommonSuperClass(type1, type2)); put(new Entry(typeCount, Symbol.MERGED_TYPE_TAG, data, hashCode)).info = commonSuperTypeIndex; return commonSuperTypeIndex; }
/** * Reads the target and creates destination class. */ protected void process() { if (targetInputStream == null) { throw new ProxettaException("Target missing: " + targetClassName); } // create class reader final ClassReader classReader; try { classReader = new ClassReader(targetInputStream); } catch (IOException ioex) { throw new ProxettaException("Error reading class input stream", ioex); } // reads information final TargetClassInfoReader targetClassInfoReader = new TargetClassInfoReader(proxetta.getClassLoader()); classReader.accept(targetClassInfoReader, 0); this.destClassWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); // create proxy if (log.isDebugEnabled()) { log.debug("processing: " + classReader.getClassName()); } WorkData wd = process(classReader, targetClassInfoReader); // store important data proxyApplied = wd.proxyApplied; proxyClassName = wd.thisReference.replace('/', '.'); }
return replaceAsmInstructions(result.data, hasFrames); } else { return result.data;
/** * Returns raw bytecode. */ protected byte[] toByteArray() { assertProxyIsCreated(); return destClassWriter.toByteArray(); }
/** * Adds a merged type in the type table of this symbol table. Does nothing if the type table * already contains a similar type. * * @param typeTableIndex1 a {@link Symbol#TYPE_TAG} type, specified by its index in the type * table. * @param typeTableIndex2 another {@link Symbol#TYPE_TAG} type, specified by its index in the type * table. * @return the index of a new or already existing {@link Symbol#TYPE_TAG} type Symbol, * corresponding to the common super class of the given types. */ int addMergedType(final int typeTableIndex1, final int typeTableIndex2) { // TODO sort the arguments? The merge result should be independent of their order. long data = typeTableIndex1 | (((long) typeTableIndex2) << 32); int hashCode = hash(Symbol.MERGED_TYPE_TAG, typeTableIndex1 + typeTableIndex2); Entry entry = get(hashCode); while (entry != null) { if (entry.tag == Symbol.MERGED_TYPE_TAG && entry.hashCode == hashCode && entry.data == data) { return entry.info; } entry = entry.next; } String type1 = typeTable[typeTableIndex1].value; String type2 = typeTable[typeTableIndex2].value; int commonSuperTypeIndex = addType(classWriter.getCommonSuperClass(type1, type2)); put(new Entry(typeCount, Symbol.MERGED_TYPE_TAG, data, hashCode)).info = commonSuperTypeIndex; return commonSuperTypeIndex; }
/** * Reads the target and creates destination class. */ protected void process() { if (targetInputStream == null) { throw new ProxettaException("Target missing: " + targetClassName); } // create class reader final ClassReader classReader; try { classReader = new ClassReader(targetInputStream); } catch (IOException ioex) { throw new ProxettaException("Error reading class input stream", ioex); } // reads information final TargetClassInfoReader targetClassInfoReader = new TargetClassInfoReader(proxetta.getClassLoader()); classReader.accept(targetClassInfoReader, 0); this.destClassWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); // create proxy if (log.isDebugEnabled()) { log.debug("processing: " + classReader.getClassName()); } WorkData wd = process(classReader, targetClassInfoReader); // store important data proxyApplied = wd.proxyApplied; proxyClassName = wd.thisReference.replace('/', '.'); }
return replaceAsmInstructions(result.data, hasFrames); } else { return result.data;
final Attribute[] attributes = getAttributePrototypes(); firstField = null; lastField = null; attributes, (hasFrames ? ClassReader.EXPAND_FRAMES : 0) | ClassReader.EXPAND_ASM_INSNS); return toByteArray();
/** * Adds a handle to the constant pool of the class being build. Does nothing if the constant pool * already contains a similar item. <i>This method is intended for {@link Attribute} sub classes, * and is normally not needed by class generators or adapters.</i> * * @param tag the kind of this handle. Must be {@link Opcodes#H_GETFIELD}, {@link * Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link * Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}. * @param owner the internal name of the field or method owner class. * @param name the name of the field or method. * @param descriptor the descriptor of the field or method. * @return the index of a new or already existing method type reference item. * @deprecated this method is superseded by {@link #newHandle(int, String, String, String, * boolean)}. */ @Deprecated public int newHandle( final int tag, final String owner, final String name, final String descriptor) { return newHandle(tag, owner, name, descriptor, tag == Opcodes.H_INVOKEINTERFACE); }
ClassLoader classLoader = getClassLoader(); Class<?> class1; try {