/** * Throws an exception when an invalid state is hit in a tableswitch */ private static void stateNotFound(final CodeAttribute c, final TableSwitchBuilder builder) { c.branchEnd(builder.getDefaultBranchEnd().get()); c.newInstruction(RuntimeException.class); c.dup(); c.ldc("Invalid character"); c.invokespecial(RuntimeException.class.getName(), "<init>", "(Ljava/lang/String;)V"); c.athrow(); }
private void createStateField(final State state, final ClassFile file, final CodeAttribute sc) { if (state.fieldName != null) { file.addField(AccessFlag.STATIC | AccessFlag.FINAL | AccessFlag.PRIVATE, state.fieldName, "[B"); sc.ldc(state.terminalState); sc.ldc("ISO-8859-1"); sc.invokevirtual(String.class.getName(), "getBytes", "(Ljava/lang/String;)[B"); sc.putstatic(file.getName(), state.fieldName, "[B"); sc.ldc(state.terminalState); } else { sc.ldc(state.soFar); sc.dup(); if (state.terminalState != null) { sc.ldc(state.terminalState); } else { sc.ldc(state.soFar);
ca.ldc(idlName); ca.getstatic(asm.getName(), strategyField, StubStrategy.class); init.dup(); init.iconst(i); init.ldc(CDRStream.abbrevFor(paramTypes[i])); init.aastore(); init.dup(); init.iconst(j); init.ldc( ExceptionAnalysis.getExceptionAnalysis(exceptions[i]) .getExceptionRepositoryId()); init.dup(); init.iconst(j); init.ldc(exceptions[i].getName()); init.aastore(); j++; init.ldc(CDRStream.abbrevFor(returnType));
c.ldc(currentState.soFar); c.invokevirtual(StringBuilder.class.getName(), "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;"); c.swap();
clinit.dup(); clinit.iconst(i); clinit.ldc(ids[i]); clinit.aastore();
/** * Adds the appropriate fconst instruction. * <p/> * note, if the value is not 0, 1, 2 then ldc is used instead */ public void fconst(float value) { if (value == 0) { writeByte(Opcode.FCONST_0); } else if (value == 1) { writeByte(Opcode.FCONST_1); } else if (value == 2) { writeByte(Opcode.FCONST_2); } else { ldc(value); return; } currentOffset++; advanceFrame(currentFrame.push("F")); }
/** * Adds the appropriate fconst instruction. * <p/> * note, if the value is not 0, 1, 2 then ldc is used instead */ public void fconst(float value) { if (value == 0) { writeByte(Opcode.FCONST_0); } else if (value == 1) { writeByte(Opcode.FCONST_1); } else if (value == 2) { writeByte(Opcode.FCONST_2); } else { ldc(value); return; } currentOffset++; advanceFrame(currentFrame.push("F")); }
/** * Adds the appropriate fconst instruction. * <p/> * note, if the value is not 0, 1, 2 then ldc is used instead */ public void fconst(float value) { if (value == 0) { writeByte(Opcode.FCONST_0); } else if (value == 1) { writeByte(Opcode.FCONST_1); } else if (value == 2) { writeByte(Opcode.FCONST_2); } else { ldc(value); return; } currentOffset++; advanceFrame(currentFrame.push("F")); }
/** * Adds the appropriate fconst instruction. * <p/> * note, if the value is not 0, 1, 2 then ldc is used instead */ public void fconst(float value) { if (value == 0) { writeByte(Opcode.FCONST_0); } else if (value == 1) { writeByte(Opcode.FCONST_1); } else if (value == 2) { writeByte(Opcode.FCONST_2); } else { ldc(value); return; } currentOffset++; advanceFrame(currentFrame.push("F")); }
/** * Adds the appropriate fconst instruction. * <p/> * note, if the value is not 0, 1, 2 then ldc is used instead */ public void fconst(float value) { if (value == 0) { writeByte(Opcode.FCONST_0); } else if (value == 1) { writeByte(Opcode.FCONST_1); } else if (value == 2) { writeByte(Opcode.FCONST_2); } else { ldc(value); return; } currentOffset++; advanceFrame(currentFrame.push("F")); }
private void addInitMethod(final String declaringClass, final String methodName, final String[] parameterTypes, String weldMethodName, ClassFile classFile) { ClassMethod initMethod = classFile.addMethod(AccessFlag.of(AccessFlag.PRIVATE, AccessFlag.STATIC), weldMethodName, LJAVA_LANG_REFLECT_METHOD); final CodeAttribute code = initMethod.getCodeAttribute(); BytecodeUtils.pushClassType(code, declaringClass); // now we have the class on the stack code.ldc(methodName); // now we need to load the parameter types into an array code.iconst(parameterTypes.length); code.anewarray(Class.class.getName()); for (int i = 0; i < parameterTypes.length; ++i) { code.dup(); // duplicate the array reference code.iconst(i); // now load the class object String type = parameterTypes[i]; BytecodeUtils.pushClassType(code, type); // and store it in the array code.aastore(); } code.invokestatic(DefaultBytecodeMethodResolver.class.getName(), "getMethod", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"); code.returnInstruction(); }
private void addInitMethod(final String declaringClass, final String methodName, final String[] parameterTypes, String weldMethodName, ClassFile classFile) { ClassMethod initMethod = classFile.addMethod(AccessFlag.of(AccessFlag.PRIVATE, AccessFlag.STATIC), weldMethodName, LJAVA_LANG_REFLECT_METHOD); final CodeAttribute code = initMethod.getCodeAttribute(); BytecodeUtils.pushClassType(code, declaringClass); // now we have the class on the stack code.ldc(methodName); // now we need to load the parameter types into an array code.iconst(parameterTypes.length); code.anewarray(Class.class.getName()); for (int i = 0; i < parameterTypes.length; ++i) { code.dup(); // duplicate the array reference code.iconst(i); // now load the class object String type = parameterTypes[i]; BytecodeUtils.pushClassType(code, type); // and store it in the array code.aastore(); } code.invokestatic(DefaultBytecodeMethodResolver.class.getName(), "getMethod", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"); code.returnInstruction(); }
private void addInitMethod(final String declaringClass, final String methodName, final String[] parameterTypes, String weldMethodName, ClassFile classFile) { ClassMethod initMethod = classFile.addMethod(AccessFlag.of(AccessFlag.PRIVATE, AccessFlag.STATIC), weldMethodName, LJAVA_LANG_REFLECT_METHOD); final CodeAttribute code = initMethod.getCodeAttribute(); BytecodeUtils.pushClassType(code, declaringClass); // now we have the class on the stack code.ldc(methodName); // now we need to load the parameter types into an array code.iconst(parameterTypes.length); code.anewarray(Class.class.getName()); for (int i = 0; i < parameterTypes.length; ++i) { code.dup(); // duplicate the array reference code.iconst(i); // now load the class object String type = parameterTypes[i]; BytecodeUtils.pushClassType(code, type); // and store it in the array code.aastore(); } code.invokestatic(DefaultBytecodeMethodResolver.class.getName(), "getMethod", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"); code.returnInstruction(); }
/** * Adds the appropriate iconst instruction. * <p/> * note, if the value is not in the range -1 to 5 ldc is written instead * * @param value */ public void iconst(int value) { if (value < -1 || value > 5) { if (value < -128 || value > 127) { ldc(value); } else { writeByte(Opcode.BIPUSH); writeByte(value); currentOffset += 2; advanceFrame(currentFrame.push("I")); } return; } writeByte(Opcode.ICONST_0 + value); currentOffset++; advanceFrame(currentFrame.push("I")); }
private void addInitMethod(final String declaringClass, final String methodName, final String[] parameterTypes, String weldMethodName, ClassFile classFile) { ClassMethod initMethod = classFile.addMethod(AccessFlag.of(AccessFlag.PRIVATE, AccessFlag.STATIC), weldMethodName, LJAVA_LANG_REFLECT_METHOD); final CodeAttribute code = initMethod.getCodeAttribute(); BytecodeUtils.pushClassType(code, declaringClass); // now we have the class on the stack code.ldc(methodName); // now we need to load the parameter types into an array code.iconst(parameterTypes.length); code.anewarray(Class.class.getName()); for (int i = 0; i < parameterTypes.length; ++i) { code.dup(); // duplicate the array reference code.iconst(i); // now load the class object String type = parameterTypes[i]; BytecodeUtils.pushClassType(code, type); // and store it in the array code.aastore(); } code.invokestatic(DefaultBytecodeMethodResolver.class.getName(), "getMethod", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"); code.returnInstruction(); }
private void addInitMethod(final String declaringClass, final String methodName, final String[] parameterTypes, String weldMethodName, ClassFile classFile) { ClassMethod initMethod = classFile.addMethod(AccessFlag.of(AccessFlag.PRIVATE, AccessFlag.STATIC), weldMethodName, LJAVA_LANG_REFLECT_METHOD); final CodeAttribute code = initMethod.getCodeAttribute(); BytecodeUtils.pushClassType(code, declaringClass); // now we have the class on the stack code.ldc(methodName); // now we need to load the parameter types into an array code.iconst(parameterTypes.length); code.anewarray(Class.class.getName()); for (int i = 0; i < parameterTypes.length; ++i) { code.dup(); // duplicate the array reference code.iconst(i); // now load the class object String type = parameterTypes[i]; BytecodeUtils.pushClassType(code, type); // and store it in the array code.aastore(); } code.invokestatic(DefaultBytecodeMethodResolver.class.getName(), "getMethod", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"); code.returnInstruction(); }
private void addInitMethod(final String declaringClass, final String methodName, final String[] parameterTypes, String weldMethodName, ClassFile classFile) { ClassMethod initMethod = classFile.addMethod(AccessFlag.of(AccessFlag.PRIVATE, AccessFlag.STATIC), weldMethodName, LJAVA_LANG_REFLECT_METHOD); final CodeAttribute code = initMethod.getCodeAttribute(); BytecodeUtils.pushClassType(code, declaringClass); // now we have the class on the stack code.ldc(methodName); // now we need to load the parameter types into an array code.iconst(parameterTypes.length); code.anewarray(Class.class.getName()); for (int i = 0; i < parameterTypes.length; ++i) { code.dup(); // duplicate the array reference code.iconst(i); // now load the class object String type = parameterTypes[i]; BytecodeUtils.pushClassType(code, type); // and store it in the array code.aastore(); } code.invokestatic(DefaultBytecodeMethodResolver.class.getName(), "getMethod", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"); code.returnInstruction(); }
/** * Adds the appropriate iconst instruction. * <p/> * note, if the value is not in the range -1 to 5 ldc is written instead * * @param value */ public void iconst(int value) { if (value < -1 || value > 5) { if(value < -128 || value > 127) { ldc(value); } else { writeByte(Opcode.BIPUSH); writeByte(value); currentOffset+=2; advanceFrame(currentFrame.push("I")); } return; } writeByte(Opcode.ICONST_0 + value); currentOffset++; advanceFrame(currentFrame.push("I")); }
/** * Adds the appropriate iconst instruction. * <p/> * note, if the value is not in the range -1 to 5 ldc is written instead * * @param value */ public void iconst(int value) { if (value < -1 || value > 5) { if (value < -128 || value > 127) { ldc(value); } else { writeByte(Opcode.BIPUSH); writeByte(value); currentOffset += 2; advanceFrame(currentFrame.push("I")); } return; } writeByte(Opcode.ICONST_0 + value); currentOffset++; advanceFrame(currentFrame.push("I")); }
/** * Adds the appropriate iconst instruction. * <p/> * note, if the value is not in the range -1 to 5 ldc is written instead * * @param value */ public void iconst(int value) { if (value < -1 || value > 5) { if (value < -128 || value > 127) { ldc(value); } else { writeByte(Opcode.BIPUSH); writeByte(value); currentOffset += 2; advanceFrame(currentFrame.push("I")); } return; } writeByte(Opcode.ICONST_0 + value); currentOffset++; advanceFrame(currentFrame.push("I")); }