public void local(int index, String name, Type type) { method.visitLocalVariable(name, type.getDescriptor(), null, start, end, index); }
private static String[] toInternalNames(final Class[] params) { if (params == null) return null; String[] names = new String[params.length]; for (int i = 0; i < names.length; ++i) { names[i] = Type.getType(params[i]).getInternalName(); } return names; }
private static Type[] toTypes(Class[] params) { Type[] types = new Type[params.length]; for (int i = 0; i < types.length; i++) { types[i] = Type.getType(params[i]); } return types; }
field_name, PROXY_METHOD_TYPE.getDescriptor(), null, null); fv.visitEnd(); .getType(Object[].class)); } else { ga.visitTryCatchBlock(before, after, rethrow, ex[i].getInternalName()); ga.visitTryCatchBlock(before, after, rethrow, "java/lang/RuntimeException"); Type thr = Type.getType(Throwable.class); Label handler = ga.mark(); Type udt = Type.getType(UndeclaredThrowableException.class); int loc = ga.newLocal(thr); ga.storeLocal(loc, thr);
AnnotationVisitor annotationV; annotationV = visitor.visitAnnotation(key, Type.getType(nestedAnnotation.getKey()).getDescriptor()); visitAnnotationFields(annotationV, nestedAnnotation.getValue()); annotationV.visitEnd(); visitor.visitEnum(key, ci(value.getClass()), value.toString()); } else if (value instanceof Class) { visitor.visit(key, Type.getType((Class) value)); } else { visitor.visit(key, value);
private JavaProxyClass generate(ClassLoader loader, String targetClassName, Class superClass, Class[] interfaces, Map<MethodKey, MethodData> methods, Type selfType) { ClassWriter cw = beginProxyClass(targetClassName, superClass, interfaces); GeneratorAdapter clazzInit = createClassInitializer(selfType, cw); generateConstructors(superClass, selfType, cw); generateGetProxyClass(selfType, cw); generateGetInvocationHandler(selfType, cw); generateProxyMethods(superClass, methods, selfType, cw, clazzInit); // finish class initializer clazzInit.returnValue(); clazzInit.endMethod(); // end class cw.visitEnd(); Class clazz = invokeDefineClass(loader, selfType.getClassName(), cw.toByteArray()); // trigger class initialization for the class try { Field proxy_class = clazz.getDeclaredField(PROXY_CLASS_FIELD_NAME); proxy_class.setAccessible(true); return (JavaProxyClass) proxy_class.get(clazz); } catch (Exception ex) { InternalError ie = new InternalError(); ie.initCause(ex); throw ie; } }
public void invokeStatic(Type type, Method method) { adapter.invokestatic(type.getInternalName(), method.getName(), method.getDescriptor()); }
Type classType = Type.getType("L" + clsName.replace('.', '/') + ';'); int tempIndex = Type.getMethodType(signature).getArgumentsAndReturnSizes() >> 2 + 1; if (sync) { adapter.ldc(classType);
field_name, PROXY_METHOD_TYPE.getDescriptor(), null, null); fv.visitEnd(); ga.visitTryCatchBlock(before, after, rethrow, ex[i].getInternalName());
public void adaptHandle(ExecutableElementDescriptor executableElementDescriptor, int implClass) { ExecutableElementDescriptor desc = executableElementDescriptor; // adapt handle mv.aload(RUNTIME); mv.ldc(calculateActualRequired(desc.method, desc.method.getParameters().size(), desc.optional, desc.rest, desc.isStatic, desc.hasContext, desc.hasBlock)); mv.ldc(desc.required); mv.ldc(desc.optional); mv.ldc(desc.rest); mv.ldc(desc.rubyName); mv.ldc(Type.getObjectType(desc.declaringClassPath)); mv.ldc(desc.isStatic); mv.ldc(desc.hasContext); mv.ldc(desc.hasBlock); mv.ldc(desc.anno.frame()); mv.aload(implClass); mv.invokestatic("org/jruby/internal/runtime/methods/InvokeDynamicMethodFactory", "adaptHandle", Method.getMethod("java.util.concurrent.Callable adaptHandle(java.lang.invoke.MethodHandle, org.jruby.Ruby, int, int, int, boolean, java.lang.String, java.lang.Class, boolean, boolean, boolean, boolean, org.jruby.RubyModule)").getDescriptor()); }
private static Type[] getType(Class[] parameterTypes) { Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = Type.getType(parameterTypes[i]); } return result; }
field_name, PROXY_METHOD_TYPE.getDescriptor(), null, null); fv.visitEnd(); .getType(Object[].class)); } else { ga.visitTryCatchBlock(before, after, rethrow, ex[i].getInternalName()); ga.visitTryCatchBlock(before, after, rethrow, "java/lang/RuntimeException"); Type thr = Type.getType(Throwable.class); Label handler = ga.mark(); Type udt = Type.getType(UndeclaredThrowableException.class); int loc = ga.newLocal(thr); ga.storeLocal(loc, thr);
AnnotationVisitor annotationV; annotationV = visitor.visitAnnotation(key, Type.getType(nestedAnnotation.getKey()).getDescriptor()); visitAnnotationFields(annotationV, nestedAnnotation.getValue()); annotationV.visitEnd(); visitor.visitEnum(key, ci(value.getClass()), value.toString()); } else if (value instanceof Class) { visitor.visit(key, Type.getType((Class) value)); } else { visitor.visit(key, value);
private JavaProxyClass generate(ClassLoader loader, String targetClassName, Class superClass, Class[] interfaces, Map<MethodKey, MethodData> methods, Type selfType) { ClassWriter cw = beginProxyClass(targetClassName, superClass, interfaces); GeneratorAdapter clazzInit = createClassInitializer(selfType, cw); generateConstructors(superClass, selfType, cw); generateGetProxyClass(selfType, cw); generateGetInvocationHandler(selfType, cw); generateProxyMethods(superClass, methods, selfType, cw, clazzInit); // finish class initializer clazzInit.returnValue(); clazzInit.endMethod(); // end class cw.visitEnd(); Class clazz = invokeDefineClass(loader, selfType.getClassName(), cw.toByteArray()); // trigger class initialization for the class try { Field proxy_class = clazz.getDeclaredField(PROXY_CLASS_FIELD_NAME); proxy_class.setAccessible(true); return (JavaProxyClass) proxy_class.get(clazz); } catch (Exception ex) { InternalError ie = new InternalError(); ie.initCause(ex); throw ie; } }
public void invokeVirtual(Type type, Method method) { adapter.invokevirtual(type.getInternalName(), method.getName(), method.getDescriptor()); }
Type classType = Type.getType("L" + clsName.replace('.', '/') + ';'); int tempIndex = Type.getMethodType(signature).getArgumentsAndReturnSizes() >> 2 + 1; if (sync) { adapter.ldc(classType);
field_name, PROXY_METHOD_TYPE.getDescriptor(), null, null); fv.visitEnd(); ga.visitTryCatchBlock(before, after, rethrow, ex[i].getInternalName());
public void adaptHandle(ExecutableElementDescriptor executableElementDescriptor, int implClass) { ExecutableElementDescriptor desc = executableElementDescriptor; // adapt handle mv.aload(RUNTIME); mv.ldc(calculateActualRequired(desc.method, desc.method.getParameters().size(), desc.optional, desc.rest, desc.isStatic, desc.hasContext, desc.hasBlock)); mv.ldc(desc.required); mv.ldc(desc.optional); mv.ldc(desc.rest); mv.ldc(desc.rubyName); mv.ldc(Type.getObjectType(desc.declaringClassPath)); mv.ldc(desc.isStatic); mv.ldc(desc.hasContext); mv.ldc(desc.hasBlock); mv.ldc(desc.anno.frame()); mv.aload(implClass); mv.invokestatic("org/jruby/internal/runtime/methods/InvokeDynamicMethodFactory", "adaptHandle", Method.getMethod("java.util.concurrent.Callable adaptHandle(java.lang.invoke.MethodHandle, org.jruby.Ruby, int, int, int, boolean, java.lang.String, java.lang.Class, boolean, boolean, boolean, boolean, org.jruby.RubyModule)").getDescriptor()); }
private Type[] getType(Class[] parameterTypes) { Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = Type.getType(parameterTypes[i]); } return result; }
AnnotationVisitor annotationV; annotationV = visitor.visitAnnotation(key, Type.getType(nestedAnnotation.getKey()).getDescriptor()); visitAnnotationFields(annotationV, nestedAnnotation.getValue()); annotationV.visitEnd(); visitor.visitEnum(key, ci(value.getClass()), value.toString()); } else if (value instanceof Class) { visitor.visit(key, Type.getType((Class) value)); } else { visitor.visit(key, value);