List of usage examples for org.objectweb.asm Opcodes V1_6
int V1_6
To view the source code for org.objectweb.asm Opcodes V1_6.
Click Source Link
From source file:org.jruby.RubyInstanceConfig.java
License:LGPL
private static int initGlobalJavaVersion() { String specVersion = specVersion = Options.BYTECODE_VERSION.load(); // stack map calculation is failing for some compilation scenarios, so // forcing both 1.5 and 1.6 to use 1.5 bytecode for the moment. if (specVersion.equals("1.5")) {// || specVersion.equals("1.6")) { return Opcodes.V1_5; } else if (specVersion.equals("1.6")) { return Opcodes.V1_6; } else if (specVersion.equals("1.7") || specVersion.equals("1.8")) { return Opcodes.V1_7; } else {//from w ww . j a v a 2 s .c om throw new RuntimeException("unsupported Java version: " + specVersion); } }
From source file:org.mustbe.consulo.ikvm.psi.stubBuilding.JavaClassStubBuilder.java
License:Apache License
public byte[] buildToBytecode() { ClassWriter classWriter = new ClassWriter(Opcodes.V1_6); buildToBytecode(classWriter);//from ww w. j a v a 2 s . com classWriter.visitEnd(); return classWriter.toByteArray(); }
From source file:org.mustbe.consulo.ikvm.psi.stubBuilding.JavaClassStubBuilder.java
License:Apache License
@Override public void buildToBytecode(ClassWriter parent) { String name = null;//from w w w .j av a 2 s .com if (StringUtil.isEmpty(myPackage)) { name = myName; } else { name = myPackage.replace(".", "/") + "/" + myName; } parent.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, name, null, null, null); for (BaseStubBuilder member : myMembers) { member.buildToBytecode(parent); } }
From source file:org.parboiled.transform.process.GroupClassGenerator.java
License:Apache License
private void generateClassBasics(final InstructionGroup group, final ClassWriter cw) { cw.visit(Opcodes.V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SYNTHETIC, group.getGroupClassType().getInternalName(), null, getBaseType().getInternalName(), null); cw.visitSource(classNode.sourceFile, null); }
From source file:org.spongepowered.mod.asm.util.ASMEventListenerFactory.java
License:MIT License
@SuppressWarnings("unchecked") private static <T> Class<T> createClass(Class<T> interf, Method input, Method output) { String className = getClassName(interf, input, output); ClassWriter cwBase = new ClassWriter(0); CheckClassAdapter cw = new CheckClassAdapter(cwBase); MethodVisitor mv;/*from ww w .j a v a2 s . c o m*/ String classNameDesc = className.replace('.', '/'); String interfaceInternalName = Type.getInternalName(interf); String inputName = input.getName(); String inputMethodDescriptor = Type.getMethodDescriptor(input); String outputParameterTypeIntName = Type.getInternalName(output.getParameterTypes()[0]); String outputTargetTypeIntName = Type.getInternalName(output.getDeclaringClass()); String outputMethodDescriptor = Type.getMethodDescriptor(output); String outputName = output.getName(); boolean isOutputInterface = output.getDeclaringClass().isInterface(); // A new class of the following form is created, with a unique name // // package org.spongepowered.mod.asm; // public class <className> extends java.lang.Object implements <interf> // // private final Object target // // public <className> (java.lang.Object target) { // super(); // this.target = target; // return; // } // // public void <inputMethod> (<inputMethodType event) { // ((outputTargetType) this.target).outputMethod((outputParameteType) event); // return // } // } // package org.spongepowered.mod.asm; // public class <className> extends java.lang.Object implements <interf> cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, classNameDesc, null, "java/lang/Object", new String[] { interfaceInternalName }); // private final Object target cw.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "target", "Ljava/lang/Object;", null, null); // Constructor // public UniqueClass (java.lang.Object target) { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "(Ljava/lang/Object;)V", null, null); mv.visitCode(); // super(); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); // this.target = target; mv.visitVarInsn(Opcodes.ALOAD, 0); // Loads this mv.visitVarInsn(Opcodes.ALOAD, 1); // Loads target (from input) mv.visitFieldInsn(Opcodes.PUTFIELD, classNameDesc, "target", "Ljava/lang/Object;"); // return; mv.visitInsn(Opcodes.RETURN); // } // 2 localvars due to inputs: this, target // 2 items on stack after double ALOAD mv.visitMaxs(2, 2); mv.visitEnd(); // Callback method // public void <inputMethod> (<inputMethodType event) { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, inputName, inputMethodDescriptor, null, null); mv.visitCode(); // push((casted) this.target) mv.visitVarInsn(Opcodes.ALOAD, 0); // Loads this mv.visitFieldInsn(Opcodes.GETFIELD, classNameDesc, "target", "Ljava/lang/Object;"); mv.visitTypeInsn(Opcodes.CHECKCAST, outputTargetTypeIntName); // push((casted) event) mv.visitVarInsn(Opcodes.ALOAD, 1); // Loads method parameter 0 mv.visitTypeInsn(Opcodes.CHECKCAST, outputParameterTypeIntName); // ((outputTargetType) this.target).outputMethod((outputParameteType) event); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, outputTargetTypeIntName, outputName, outputMethodDescriptor, isOutputInterface); // return mv.visitInsn(Opcodes.RETURN); // } mv.visitMaxs(2, 2); mv.visitEnd(); cw.visitEnd(); byte[] bytes = cwBase.toByteArray(); return (Class<T>) loader.defineClass(className, bytes); }
From source file:org.spongepowered.mod.event.HandlerClassFactory.java
License:MIT License
public byte[] generateClass(Class<?> objectClass, Method method, Class<?> eventClass, boolean ignoreCancelled, String className) {//from w ww .j a v a 2 s .co m ClassWriter cw = new ClassWriter(COMPUTE_FRAMES | COMPUTE_MAXS); FieldVisitor fv; MethodVisitor mv; String createdInternalName = className.replace(".", "/"); String invokedInternalName = Type.getInternalName(objectClass); String eventInternalName = Type.getInternalName(eventClass); cw.visit(Opcodes.V1_6, ACC_PUBLIC + ACC_SUPER, createdInternalName, null, "java/lang/Object", new String[] { Type.getInternalName(Handler.class) }); { fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "object", "L" + invokedInternalName + ";", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE + ACC_FINAL, "method", "Ljava/lang/reflect/Method;", null, null); fv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "(L" + invokedInternalName + ";Ljava/lang/reflect/Method;)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); mv.visitFieldInsn(PUTFIELD, createdInternalName, "object", "L" + invokedInternalName + ";"); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 2); mv.visitFieldInsn(PUTFIELD, createdInternalName, "method", "Ljava/lang/reflect/Method;"); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "handle", "(Lorg/spongepowered/api/util/event/Event;)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, createdInternalName, "object", "L" + invokedInternalName + ";"); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(CHECKCAST, eventInternalName); mv.visitMethodInsn(INVOKEVIRTUAL, "" + invokedInternalName + "", method.getName(), "(L" + eventInternalName + ";)V", false); mv.visitInsn(RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, 1); Label l0 = new Label(); mv.visitJumpInsn(IF_ACMPNE, l0); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 1); Label l1 = new Label(); mv.visitJumpInsn(IFNULL, l1); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;", false); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;", false); Label l2 = new Label(); mv.visitJumpInsn(IF_ACMPEQ, l2); mv.visitLabel(l1); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitLabel(l2); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(CHECKCAST, createdInternalName); mv.visitVarInsn(ASTORE, 2); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, createdInternalName, "method", "Ljava/lang/reflect/Method;"); mv.visitVarInsn(ALOAD, 2); mv.visitFieldInsn(GETFIELD, createdInternalName, "method", "Ljava/lang/reflect/Method;"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/Method", "equals", "(Ljava/lang/Object;)Z", false); Label l3 = new Label(); mv.visitJumpInsn(IFNE, l3); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitLabel(l3); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, createdInternalName, "object", "L" + invokedInternalName + ";"); mv.visitVarInsn(ALOAD, 2); mv.visitFieldInsn(GETFIELD, createdInternalName, "object", "L" + invokedInternalName + ";"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z", false); Label l4 = new Label(); mv.visitJumpInsn(IFNE, l4); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitLabel(l4); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "hashCode", "()I", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, createdInternalName, "object", "L" + invokedInternalName + ";"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I", false); mv.visitVarInsn(ISTORE, 1); mv.visitIntInsn(BIPUSH, 31); mv.visitVarInsn(ILOAD, 1); mv.visitInsn(IMUL); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, createdInternalName, "method", "Ljava/lang/reflect/Method;"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/Method", "hashCode", "()I", false); mv.visitInsn(IADD); mv.visitVarInsn(ISTORE, 1); mv.visitVarInsn(ILOAD, 1); mv.visitInsn(IRETURN); mv.visitMaxs(2, 2); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
From source file:org.springframework.xd.fluent.internal.CustomizedModuleGenerator.java
License:Apache License
/** * @param inDescriptor input descriptor of the form Lfoo/Bar; * @param outDescriptor output descriptor of the form Lfoo/Boo; *///from ww w .j a va 2 s. c o m private static void writeCustomCode(ZipOutputStream zos, String inDescriptor, String outDescriptor) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC | Opcodes.ACC_SUPER, "org/springframework/xd/code/Code", null, "org/springframework/xd/code/CodeDrivenProcessor", null); MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "org/springframework/xd/code/CodeDrivenProcessor", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // An example transform method that picks even number chars from the input payload and makes that into the output mv = cw.visitMethod(ACC_PUBLIC, "transform", "(" + inDescriptor + ")" + outDescriptor, null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "org/springframework/xd/code/Code", "fn", "Ljava/util/function/Function;"); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/function/Function", "apply", "(Ljava/lang/Object;)Ljava/lang/Object;", true); mv.visitTypeInsn(CHECKCAST, outDescriptor.substring(1, outDescriptor.length() - 1));//"java/lang/Integer"); mv.visitInsn(ARETURN); mv.visitMaxs(2, 2); mv.visitEnd(); cw.visitEnd(); try { zos.write(cw.toByteArray()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:pl.clareo.coroutines.core.ClassTransformer.java
License:Apache License
@SuppressWarnings("unchecked") void transform() { for (MethodNode coroutine : coroutines) { if (log.isLoggable(Level.FINEST)) { log.finest("Generating method for coroutine " + coroutine.name + coroutine.desc); }/*www .j av a 2 s .c o m*/ String coroutineName = getCoroutineName(coroutine); MethodTransformer methodTransformer = new MethodTransformer(coroutine, thisType); MethodNode coroutineImpl = methodTransformer.transform(coroutineName, generateDebugCode); thisNode.methods.add(coroutineImpl); /* * generate co iterators and method stubs */ log.finest("Generating CoIterator implementation and method stubs"); String baseCoIteratorName; Map<String, Object> annotation = getCoroutineAnnotationValues(coroutine); if (getBoolean(annotation, "threadLocal")) { baseCoIteratorName = Type.getInternalName(ThreadLocalCoIterator.class); } else { baseCoIteratorName = Type.getInternalName(SingleThreadedCoIterator.class); } String coIteratorClassName = "pl/clareo/coroutines/core/CoIterator" + num; ClassNode coIteratorClass = new ClassNode(); coIteratorClass.version = Opcodes.V1_6; coIteratorClass.access = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER; coIteratorClass.name = coIteratorClassName; coIteratorClass.superName = baseCoIteratorName; if (generateDebugCode) { /* * If debugging code is emitted create field keeping JDK logger */ FieldNode loggerField = new FieldNode(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC, "logger", "Ljava/util/logging/Logger;", null, null); coIteratorClass.fields.add(loggerField); MethodNode clinit = new MethodNode(); clinit.access = Opcodes.ACC_STATIC; clinit.name = "<clinit>"; clinit.desc = "()V"; clinit.exceptions = Collections.EMPTY_LIST; String loggerName = thisType.getClassName(); InsnList clinitCode = clinit.instructions; clinitCode.add(new LdcInsnNode(loggerName)); clinitCode.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/util/logging/Logger", "getLogger", "(Ljava/lang/String;)Ljava/util/logging/Logger;")); clinitCode.add(new FieldInsnNode(Opcodes.PUTSTATIC, coIteratorClassName, "logger", "Ljava/util/logging/Logger;")); clinitCode.add(new InsnNode(Opcodes.RETURN)); clinit.maxStack = 1; clinit.maxLocals = 0; coIteratorClass.methods.add(clinit); } /* * Generate constructor */ MethodNode init = new MethodNode(); init.access = Opcodes.ACC_PUBLIC; init.name = "<init>"; init.desc = CO_ITERATOR_CONSTRUCTOR_DESCRIPTOR; init.exceptions = Collections.EMPTY_LIST; InsnList initCode = init.instructions; initCode.add(new VarInsnNode(Opcodes.ALOAD, 0)); initCode.add(new VarInsnNode(Opcodes.ALOAD, 1)); initCode.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, baseCoIteratorName, "<init>", CO_ITERATOR_CONSTRUCTOR_DESCRIPTOR)); initCode.add(new InsnNode(Opcodes.RETURN)); init.maxStack = 2; init.maxLocals = 2; coIteratorClass.methods.add(init); /* * Generate overriden call to coroutine */ MethodNode call = new MethodNode(); call.access = Opcodes.ACC_PROTECTED; call.name = "call"; call.desc = CALL_METHOD_DESCRIPTOR; call.exceptions = Collections.EMPTY_LIST; InsnList callCode = call.instructions; /* * if debug needed generate call details */ if (generateDebugCode) { String coroutineId = "Coroutine " + coroutine.name; callCode.add(loggingInstructions(coIteratorClassName, "logger", Level.FINER, coroutineId + " call. Caller sent: ", 2)); callCode.add(new FrameNode(Opcodes.F_SAME, 0, EMPTY_LOCALS, 0, EMPTY_STACK)); callCode.add(loggingInstructions(coIteratorClassName, "logger", Level.FINEST, coroutineId + " state ", 1)); callCode.add(new FrameNode(Opcodes.F_SAME, 0, EMPTY_LOCALS, 0, EMPTY_STACK)); } /* * push call arguments: this (if not static), frame, input, output */ boolean isStatic = (coroutine.access & Opcodes.ACC_STATIC) != 0; if (!isStatic) { callCode.add(new VarInsnNode(Opcodes.ALOAD, 1)); callCode.add( new MethodInsnNode(Opcodes.INVOKEVIRTUAL, FRAME_NAME, "getThis", "()Ljava/lang/Object;")); callCode.add(new TypeInsnNode(Opcodes.CHECKCAST, thisType.getInternalName())); } callCode.add(new VarInsnNode(Opcodes.ALOAD, 1)); callCode.add(new InsnNode(Opcodes.ACONST_NULL)); callCode.add(new VarInsnNode(Opcodes.ALOAD, 2)); callCode.add(new MethodInsnNode(isStatic ? Opcodes.INVOKESTATIC : Opcodes.INVOKEVIRTUAL, thisType.getInternalName(), coroutineName, COROUTINE_METHOD_DESCRIPTOR)); // stack: * if (!generateDebugCode) { callCode.add(new InsnNode(Opcodes.ARETURN)); } else { // save result display suspension point (two more locals // needed) callCode.add(new VarInsnNode(Opcodes.ASTORE, 3)); callCode.add(new VarInsnNode(Opcodes.ALOAD, 1)); callCode.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, FRAME_NAME, "getLineOfCode", "()I")); callCode.add(box_int(Type.INT)); callCode.add(new VarInsnNode(Opcodes.ASTORE, 4)); callCode.add(loggingInstructions(coIteratorClassName, "logger", Level.FINER, "Coroutine suspended at line ", 4, ". Yielded:", 3)); callCode.add(new FrameNode(Opcodes.F_APPEND, 2, new Object[] { "java/lang/Object", "java/lang/Integer" }, 0, EMPTY_STACK)); callCode.add(new VarInsnNode(Opcodes.ALOAD, 3)); callCode.add(new InsnNode(Opcodes.ARETURN)); } coIteratorClass.methods.add(call); // if debugging code is emitted it needs space for two // additional locals and 5 stack operand if (generateDebugCode) { call.maxStack = 5; call.maxLocals = 5; } else { if (isStatic) { call.maxStack = 3; } else { call.maxStack = 4; } call.maxLocals = 3; } /* * CoIterator created - define it in the runtime and verify if * needed */ if (log.isLoggable(Level.FINEST)) { log.finest("Generated class " + coIteratorClassName); } ClassWriter cw = new ClassWriter(0); coIteratorClass.accept(cw); byte[] classBytes = cw.toByteArray(); try { CoroutineInstrumentator.dumpClass(coIteratorClassName, classBytes); } catch (IOException e) { throw new CoroutineGenerationException("Unable to write class " + coIteratorClassName, e); } /* * start generating method - new method is named as the method in * user code, it: returns instance of appropriate CoIterator (see * above), saves arguments of call */ if (log.isLoggable(Level.FINEST)) { log.finest("Instrumenting method " + coroutine.name); } InsnList code = coroutine.instructions; code.clear(); /* * create new Frame */ boolean isDebugFramePossible = generateDebugCode && coroutine.localVariables != null; if (isDebugFramePossible) { code.add(createDebugFrame(coroutine)); } else { code.add(createFrame(coroutine)); } /* * save frame in the first, and locals array in the second local * variable */ int argsSize = Type.getArgumentsAndReturnSizes(coroutine.desc) >> 2; if (isStatic) { argsSize -= 1; } code.add(new VarInsnNode(Opcodes.ASTORE, argsSize)); code.add(new VarInsnNode(Opcodes.ALOAD, argsSize)); code.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, FRAME_NAME, "getLocals", "()[Ljava/lang/Object;")); int localsArrayIndex = argsSize + 1; code.add(new VarInsnNode(Opcodes.ASTORE, localsArrayIndex)); /* * save all call arguments (along with this if this method is not * static) into locals array */ Type[] argsTypes = Type.getArgumentTypes(coroutine.desc); if (!isStatic) { code.add(saveloc(localsArrayIndex, 0, 0, JAVA_LANG_OBJECT)); code.add(savelocs(localsArrayIndex, 1, 1, argsTypes)); } else { code.add(savelocs(localsArrayIndex, 0, 0, argsTypes)); } /* * create CoIterator instance with saved frame, make initial call to * next if needed and return to caller */ code.add(new TypeInsnNode(Opcodes.NEW, coIteratorClassName)); code.add(new InsnNode(Opcodes.DUP)); code.add(new VarInsnNode(Opcodes.ALOAD, argsSize)); code.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, coIteratorClassName, "<init>", CO_ITERATOR_CONSTRUCTOR_DESCRIPTOR)); if (!getBoolean(annotation, "generator", true)) { code.add(new InsnNode(Opcodes.DUP)); code.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, coIteratorClassName, "next", "()Ljava/lang/Object;")); code.add(new InsnNode(Opcodes.POP)); } code.add(new InsnNode(Opcodes.ARETURN)); /* * end method generation; maxs can be statically determined 3 * operands on stack (call to frame setLocals and CoIterator * constructor) + 1 if any argument is long or double (debug frame * needs 7 operands for variable names creation); locals = argsSize * + 1 reference to frame + 1 array of locals */ if (isDebugFramePossible) { coroutine.maxStack = 7; } else { boolean isCategory2ArgumentPresent = false; for (Type argType : argsTypes) { int sort = argType.getSort(); if (sort == Type.LONG || sort == Type.DOUBLE) { isCategory2ArgumentPresent = true; break; } } coroutine.maxStack = isCategory2ArgumentPresent ? 4 : 3; } coroutine.maxLocals = localsArrayIndex + 1; coroutine.localVariables.clear(); coroutine.tryCatchBlocks.clear(); num++; } }
From source file:pxb.android.dex2jar.v3.V3ClassAdapter.java
License:Apache License
protected void build() { if (!build) { String signature = null;/*from w ww . j ava 2 s . co m*/ for (Iterator<Ann> it = anns.iterator(); it.hasNext();) { Ann ann = it.next(); if ("Ldalvik/annotation/Signature;".equals(ann.type)) { it.remove(); for (Item item : ann.items) { if (item.name.equals("value")) { Ann values = (Ann) item.value; StringBuilder sb = new StringBuilder(); for (Item i : values.items) { sb.append(i.value.toString()); } signature = sb.toString(); } } } } access_flags |= Opcodes.ACC_SUPER;// ?classdx???? cv.visit(Opcodes.V1_6, access_flags | 0x20, className, signature, superClass, interfaceNames); for (Ann ann : anns) { if (ann.type.equals("Ldalvik/annotation/MemberClasses;")) { for (Item i : ann.items) { if (i.name.equals("value")) { for (Item j : ((Ann) i.value).items) { String name = j.value.toString(); Integer access = accessFlagsMap.get(name); int d = name.lastIndexOf('$'); String innerName = name.substring(d + 1, name.length() - 1); // TODO cv.visitInnerClass(name, className, innerName, access == null ? 0 : access); } } } continue; } else if (ann.type.equals("Ldalvik/annotation/EnclosingClass;")) { for (Item i : ann.items) { if (i.name.equals("value")) { Type t = (Type) i.value; int d = className.lastIndexOf('$'); String innerName = className.substring(d + 1, className.length() - 1); cv.visitInnerClass(className, t.toString(), innerName, access_flags); } } continue; } else if (ann.type.equals("Ldalvik/annotation/InnerClass;")) { continue; } AnnotationVisitor av = cv.visitAnnotation(ann.type, ann.visible); V3AnnAdapter.accept(ann.items, av); av.visitEnd(); } if (file != null) { cv.visitSource(file, null); } build = true; } }
From source file:scouter.agent.AgentTransformer.java
License:Apache License
private ClassWriter getClassWriter(final ClassDesc classDesc) { ClassWriter cw;/*from ww w .j av a 2s . c o m*/ switch (classDesc.version) { case Opcodes.V1_1: case Opcodes.V1_2: case Opcodes.V1_3: case Opcodes.V1_4: case Opcodes.V1_5: case Opcodes.V1_6: cw = new ScouterClassWriter(ClassWriter.COMPUTE_MAXS); break; default: cw = new ScouterClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); } return cw; }