/** * Returns the internal names of the given types. * * @param types * a set of types. * @return the internal names of the given types. */ private static String[] getInternalNames(final Type[] types) { if (types == null) { return null; } String[] names = new String[types.length]; for (int i = 0; i < names.length; ++i) { names[i] = types[i].getInternalName(); } return names; }
@Override public void visitInnerClass(String name, String outerName, String innerName, int access) { if(name.equals(LOOKUP_TYPE.getInternalName()) && outerName.equals(HANDLES_TYPE.getInternalName()) && LOOKUP_NAME.equals(innerName)) { lambadaInnerClassVisited = true; } super.visitInnerClass(name, outerName, innerName, access); }
/** * Generates a type dependent instruction. * * @param opcode * the instruction's opcode. * @param type * the instruction's operand. */ private void typeInsn(final int opcode, final Type type) { mv.visitTypeInsn(opcode, type.getInternalName()); }
public void anew(final Type type) { mv.visitTypeInsn(Opcodes.NEW, type.getInternalName()); }
public void instanceOf(final Type type) { mv.visitTypeInsn(Opcodes.INSTANCEOF, type.getInternalName()); }
public void checkcast(final Type type) { mv.visitTypeInsn(Opcodes.CHECKCAST, type.getInternalName()); }
protected void completeTransactions() { loadLocal(transLocal); mv.visitMethodInsn(INVOKEINTERFACE, TRANS_TYPE.getInternalName(), COMPLETE_ALL, "()V", true); } }
protected void setRollbackTransactions() { loadLocal(transLocal); mv.visitMethodInsn(INVOKEINTERFACE, TRANS_TYPE.getInternalName(), SET_ROLLBACK_ALL, "()V", true); }
protected void exitMonitor() { loadLocal(monitorLocal); mv.visitMethodInsn(INVOKEINTERFACE, MONITOR_TYPE.getInternalName(), EXIT, "()V", true); } }
public String mapType(String type) { if (type == null) { return null; } return mapType(Type.getObjectType(type)).getInternalName(); }
/** * Generates a get field or set field instruction. * * @param opcode * the instruction's opcode. * @param ownerType * the class in which the field is defined. * @param name * the name of the field. * @param fieldType * the type of the field. */ private void fieldInsn(final int opcode, final Type ownerType, final String name, final Type fieldType) { mv.visitFieldInsn(opcode, ownerType.getInternalName(), name, fieldType.getDescriptor()); }
protected void notifyMonitorError(int errLocal) { loadLocal(monitorLocal); loadLocal(errLocal); mv.visitMethodInsn(INVOKEINTERFACE, MONITOR_TYPE.getInternalName(), ERROR, "(Ljava/lang/Throwable;)V", true); }
public static Class<?> getClassType(Type type) { switch (type.getSort()) { case Type.BOOLEAN: return Boolean.TYPE; case Type.CHAR: return Character.TYPE; case Type.BYTE: return Byte.TYPE; case Type.SHORT: return Short.TYPE; case Type.INT: return Integer.TYPE; case Type.FLOAT: return Float.TYPE; case Type.LONG: return Long.TYPE; case Type.DOUBLE: return Double.TYPE; case Type.VOID: return Void.TYPE; } String cn = type.getInternalName(); cn = cn != null ? cn.replace('/', '.') : type.getClassName(); return Classes.forName(cn); }
protected void getTransactionManager() { if(!methodBodyOnly) { mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(GETFIELD, type.getInternalName(), MANAGER_FIELD, MANAGER_TYPE.getDescriptor()); }else{ invokeStatic(TxInst.TYPE,TxInst.MANAGER); } }
break; default: mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName()); return;
/** * Marks the start of an exception handler. * * @param start * beginning of the exception handler's scope (inclusive). * @param end * end of the exception handler's scope (exclusive). * @param exception * internal name of the type of exceptions handled by the * handler. */ public void catchException(final Label start, final Label end, final Type exception) { if (exception == null) { mv.visitTryCatchBlock(start, end, mark(), null); } else { mv.visitTryCatchBlock(start, end, mark(), exception.getInternalName()); } } }
/** * Generates an invoke method instruction. * * @param opcode * the instruction's opcode. * @param type * the class in which the method is defined. * @param method * the method to be invoked. */ private void invokeInsn(final int opcode, final Type type, final Method method, final boolean itf) { String owner = type.getSort() == Type.ARRAY ? type.getDescriptor() : type.getInternalName(); mv.visitMethodInsn(opcode, owner, method.getName(), method.getDescriptor(), itf); }
void addType(final Type t) { switch (t.getSort()) { case Type.ARRAY: addType(t.getElementType()); break; case Type.OBJECT: addName(t.getInternalName()); break; case Type.METHOD: addMethodDesc(t.getDescriptor()); break; } }
public String mapDesc(String desc) { Type t = Type.getType(desc); switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return s; case Type.OBJECT: String newType = map(t.getInternalName()); if (newType != null) { return 'L' + newType + ';'; } } return desc; }
private Type mapType(Type t) { switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return Type.getType(s); case Type.OBJECT: s = map(t.getInternalName()); return s != null ? Type.getObjectType(s) : t; case Type.METHOD: return Type.getMethodType(mapMethodDesc(t.getDescriptor())); } return t; }