Java Code Examples for jdk.internal.org.objectweb.asm.type#getInternalName()
The following examples show how to use
jdk.internal.org.objectweb.asm.type#getInternalName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Proxy.java From totallylazy with Apache License 2.0 | 6 votes |
public static byte[] bytes(String name, Class<?> superClass) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); String superName = Type.getInternalName(superClass); cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, name, null, superName, null); handlerField(cw); for (Method method : sequence(superClass.getMethods()). reject(m -> isFinal(m.getModifiers())). reject(m -> isStatic(m.getModifiers())). reject(m -> m.getName().equals("toString"))) { method(cw, name, method, superName); } cw.visitEnd(); return cw.toByteArray(); }
Example 2
Source File: JavaAdapterBytecodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static String getGeneratedClassName(final Class<?> superType, final List<Class<?>> interfaces) { // The class we use to primarily name our adapter is either the superclass, or if it is Object (meaning we're // just implementing interfaces or extending Object), then the first implemented interface or Object. final Class<?> namingType = superType == Object.class ? (interfaces.isEmpty()? Object.class : interfaces.get(0)) : superType; final Package pkg = namingType.getPackage(); final String namingTypeName = Type.getInternalName(namingType); final StringBuilder buf = new StringBuilder(); if (namingTypeName.startsWith(JAVA_PACKAGE_PREFIX) || pkg == null || pkg.isSealed()) { // Can't define new classes in java.* packages buf.append(ADAPTER_PACKAGE_PREFIX).append(namingTypeName); } else { buf.append(namingTypeName).append(ADAPTER_CLASS_NAME_SUFFIX); } final Iterator<Class<?>> it = interfaces.iterator(); if(superType == Object.class && it.hasNext()) { it.next(); // Skip first interface, it was used to primarily name the adapter } // Append interface names to the adapter name while(it.hasNext()) { buf.append("$$").append(it.next().getSimpleName()); } return buf.toString().substring(0, Math.min(MAX_GENERATED_TYPE_NAME_LENGTH, buf.length())); }
Example 3
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static String getGeneratedClassName(final Class<?> superType, final List<Class<?>> interfaces) { // The class we use to primarily name our adapter is either the superclass, or if it is Object (meaning we're // just implementing interfaces or extending Object), then the first implemented interface or Object. final Class<?> namingType = superType == Object.class ? (interfaces.isEmpty()? Object.class : interfaces.get(0)) : superType; final Package pkg = namingType.getPackage(); final String namingTypeName = Type.getInternalName(namingType); final StringBuilder buf = new StringBuilder(); buf.append(ADAPTER_PACKAGE_INTERNAL).append(namingTypeName.replace('/', '_')); final Iterator<Class<?>> it = interfaces.iterator(); if(superType == Object.class && it.hasNext()) { it.next(); // Skip first interface, it was used to primarily name the adapter } // Append interface names to the adapter name while(it.hasNext()) { buf.append("$$").append(it.next().getSimpleName()); } return buf.toString().substring(0, Math.min(MAX_GENERATED_TYPE_NAME_LENGTH, buf.length())); }
Example 4
Source File: Proxy.java From totallylazy with Apache License 2.0 | 6 votes |
private static void loadArguments(MethodVisitor mv, Method method) { int arguments = method.getParameterCount(); mv.visitLdcInsn(arguments); mv.visitTypeInsn(ANEWARRAY, "java/lang/Object"); Class<?>[] parameterTypes = method.getParameterTypes(); for (int i = 0, local = 0; i < parameterTypes.length; i++) { Class<?> parameterType = parameterTypes[i]; local++; mv.visitInsn(DUP); mv.visitLdcInsn(i); mv.visitVarInsn(Asm.load(parameterType), local); if (parameterType.isPrimitive() && !parameterType.equals(void.class)) { String internalName = Type.getInternalName(Reflection.box(parameterType)); mv.visitMethodInsn(INVOKESTATIC, internalName, "valueOf", format("(%s)L%s;", Type.getDescriptor(parameterType), internalName), false); } if (parameterType.equals(double.class) || parameterType.equals(long.class)) local++; mv.visitInsn(AASTORE); } }
Example 5
Source File: JavaAdapterBytecodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static String getGeneratedClassName(final Class<?> superType, final List<Class<?>> interfaces) { // The class we use to primarily name our adapter is either the superclass, or if it is Object (meaning we're // just implementing interfaces or extending Object), then the first implemented interface or Object. final Class<?> namingType = superType == Object.class ? (interfaces.isEmpty()? Object.class : interfaces.get(0)) : superType; final Package pkg = namingType.getPackage(); final String namingTypeName = Type.getInternalName(namingType); final StringBuilder buf = new StringBuilder(); if (namingTypeName.startsWith(JAVA_PACKAGE_PREFIX) || pkg == null || pkg.isSealed()) { // Can't define new classes in java.* packages buf.append(ADAPTER_PACKAGE_PREFIX).append(namingTypeName); } else { buf.append(namingTypeName).append(ADAPTER_CLASS_NAME_SUFFIX); } final Iterator<Class<?>> it = interfaces.iterator(); if(superType == Object.class && it.hasNext()) { it.next(); // Skip first interface, it was used to primarily name the adapter } // Append interface names to the adapter name while(it.hasNext()) { buf.append("$$").append(it.next().getSimpleName()); } return buf.toString().substring(0, Math.min(MAX_GENERATED_TYPE_NAME_LENGTH, buf.length())); }
Example 6
Source File: JavaAdapterBytecodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static String[] getExceptionNames(final Class<?>[] exceptions) { final String[] exceptionNames = new String[exceptions.length]; for (int i = 0; i < exceptions.length; ++i) { exceptionNames[i] = Type.getInternalName(exceptions[i]); } return exceptionNames; }
Example 7
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Given a list of class objects, return an array with their binary names. Used to generate the array of interface * names to implement. * @param classes the classes * @return an array of names */ private static String[] getInternalTypeNames(final List<Class<?>> classes) { final int interfaceCount = classes.size(); final String[] interfaceNames = new String[interfaceCount]; for(int i = 0; i < interfaceCount; ++i) { interfaceNames[i] = Type.getInternalName(classes.get(i)); } return interfaceNames; }
Example 8
Source File: LocalVariablesSorter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Creates a new local variable of the given type. * * @param type * the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT; break; case Type.LONG: t = Opcodes.LONG; break; case Type.DOUBLE: t = Opcodes.DOUBLE; break; case Type.ARRAY: t = type.getDescriptor(); break; // case Type.OBJECT: default: t = type.getInternalName(); break; } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, t); changed = true; return local; }
Example 9
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static String[] getExceptionNames(final Class<?>[] exceptions) { final String[] exceptionNames = new String[exceptions.length]; for (int i = 0; i < exceptions.length; ++i) { exceptionNames[i] = Type.getInternalName(exceptions[i]); } return exceptionNames; }
Example 10
Source File: JavaAdapterBytecodeGenerator.java From hottub with GNU General Public License v2.0 | 5 votes |
private static String[] getExceptionNames(final Class<?>[] exceptions) { final String[] exceptionNames = new String[exceptions.length]; for (int i = 0; i < exceptions.length; ++i) { exceptionNames[i] = Type.getInternalName(exceptions[i]); } return exceptionNames; }
Example 11
Source File: JavaAdapterBytecodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Given a list of class objects, return an array with their binary names. Used to generate the array of interface * names to implement. * @param classes the classes * @return an array of names */ private static String[] getInternalTypeNames(final List<Class<?>> classes) { final int interfaceCount = classes.size(); final String[] interfaceNames = new String[interfaceCount]; for(int i = 0; i < interfaceCount; ++i) { interfaceNames[i] = Type.getInternalName(classes.get(i)); } return interfaceNames; }
Example 12
Source File: JavaAdapterBytecodeGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static String[] getExceptionNames(final Class<?>[] exceptions) { final String[] exceptionNames = new String[exceptions.length]; for (int i = 0; i < exceptions.length; ++i) { exceptionNames[i] = Type.getInternalName(exceptions[i]); } return exceptionNames; }
Example 13
Source File: LocalVariablesSorter.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates a new local variable of the given type. * * @param type * the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT; break; case Type.LONG: t = Opcodes.LONG; break; case Type.DOUBLE: t = Opcodes.DOUBLE; break; case Type.ARRAY: t = type.getDescriptor(); break; // case Type.OBJECT: default: t = type.getInternalName(); break; } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, t); changed = true; return local; }
Example 14
Source File: LocalVariablesSorter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates a new local variable of the given type. * * @param type * the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT; break; case Type.LONG: t = Opcodes.LONG; break; case Type.DOUBLE: t = Opcodes.DOUBLE; break; case Type.ARRAY: t = type.getDescriptor(); break; // case Type.OBJECT: default: t = type.getInternalName(); break; } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, t); changed = true; return local; }
Example 15
Source File: JavaAdapterBytecodeGenerator.java From nashorn with GNU General Public License v2.0 | 5 votes |
private static String[] getExceptionNames(final Class<?>[] exceptions) { final String[] exceptionNames = new String[exceptions.length]; for (int i = 0; i < exceptions.length; ++i) { exceptionNames[i] = Type.getInternalName(exceptions[i]); } return exceptionNames; }
Example 16
Source File: GeneratorAdapter.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 17
Source File: GeneratorAdapter.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 18
Source File: GeneratorAdapter.java From jdk8u_jdk with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 19
Source File: GeneratorAdapter.java From TencentKona-8 with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 20
Source File: GeneratorAdapter.java From dragonwell8_jdk with GNU General Public License v2.0 | 3 votes |
/** * 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); }