public static byte[] tailor( Class templateClass, String newClassName, String... replacements ) { String vmname = toVMClassName(templateClass); return tailor( SecureLoader.getClassClassLoader(templateClass).getResourceAsStream(vmname+".class"), vmname, newClassName, replacements ); }
/** * Customizes a class file by replacing constant pools. * * @param templateClassName * The resource that contains the template class file. * @param replacements * A list of pair of strings that specify the substitution * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n } * * The search strings found in the constant pool will be replaced by the corresponding * replacement string. */ private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) { InputStream resource; if(CLASS_LOADER!=null) resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class"); else resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class"); if(resource==null) return null; return ClassTailor.tailor(resource,templateClassName,newClassName,replacements); }
/** * Returns the class name in the JVM format (such as "java/lang/String") */ public static String toVMClassName( Class c ) { assert !c.isPrimitive(); if(c.isArray()) // I have no idea why it is designed like this, but javap says so. return toVMTypeName(c); return c.getName().replace('.','/'); }
String newClassName = toVMClassName(field.getDeclaringClass())+"$JaxbAccessorF_"+field.getName(); fieldTemplateName+RuntimeUtil.primitiveToBox.get(field.getType()).getSimpleName(), newClassName, toVMClassName(Bean.class), toVMClassName(field.getDeclaringClass()), "f_"+field.getType().getName(), field.getName() ); fieldTemplateName+"Ref", newClassName, toVMClassName(Bean.class), toVMClassName(field.getDeclaringClass()), toVMClassName(Ref.class), toVMClassName(field.getType()), toVMTypeName(Ref.class), toVMTypeName(field.getType()), "f_ref", field.getName() );
String newClassName = toVMClassName(dc)+"_JaxbXducedAccessor_"+prop.getName(); fieldTemplateName+suffixMap.get(t), newClassName, toVMClassName(Bean.class), toVMClassName(dc), "f_"+t.getName(), field.getName() ); methodTemplateName+suffixMap.get(t), newClassName, toVMClassName(Bean.class), toVMClassName(dc), "get_"+t.getName(), gacc.getter.getName(),
public static byte[] tailor( Class templateClass, String newClassName, String... replacements ) { String vmname = toVMClassName(templateClass); return tailor( SecureLoader.getClassClassLoader(templateClass).getResourceAsStream(vmname+".class"), vmname, newClassName, replacements ); }
public static String toVMTypeName( Class c ) { if(c.isArray()) { // TODO: study how an array type is encoded. return '['+toVMTypeName(c.getComponentType()); } if(c.isPrimitive()) { if(c==Boolean.TYPE) return "Z"; if(c==Character.TYPE) return "C"; if(c==Byte.TYPE) return "B"; if(c==Double.TYPE) return "D"; if(c==Float.TYPE) return "F"; if(c==Integer.TYPE) return "I"; if(c==Long.TYPE) return "J"; if(c==Short.TYPE) return "S"; throw new IllegalArgumentException(c.getName()); } return 'L'+c.getName().replace('.','/')+';'; }
String newClassName = toVMClassName(getter.getDeclaringClass())+"$JaxbAccessorM_"+getter.getName()+'_'+setter.getName()+'_'+typeName; Class opt; methodTemplateName+RuntimeUtil.primitiveToBox.get(t).getSimpleName(), newClassName, toVMClassName(Bean.class), toVMClassName(getter.getDeclaringClass()), "get_"+t.getName(), getter.getName(), methodTemplateName+"Ref", newClassName, toVMClassName(Bean.class), toVMClassName(getter.getDeclaringClass()), toVMClassName(Ref.class), toVMClassName(t), "()"+toVMTypeName(Ref.class), "()"+toVMTypeName(t), '('+toVMTypeName(Ref.class)+")V", '('+toVMTypeName(t)+")V",
/** * Customizes a class file by replacing constant pools. * * @param templateClassName * The resource that contains the template class file. * @param replacements * A list of pair of strings that specify the substitution * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n } * * The search strings found in the constant pool will be replaced by the corresponding * replacement string. */ private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) { InputStream resource; if(CLASS_LOADER!=null) resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class"); else resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class"); if(resource==null) return null; return ClassTailor.tailor(resource,templateClassName,newClassName,replacements); }
public static byte[] tailor( Class templateClass, String newClassName, String... replacements ) { String vmname = toVMClassName(templateClass); return tailor( SecureLoader.getClassClassLoader(templateClass).getResourceAsStream(vmname+".class"), vmname, newClassName, replacements ); }
/** * Returns the class name in the JVM format (such as "java/lang/String") */ public static String toVMClassName( Class c ) { assert !c.isPrimitive(); if(c.isArray()) // I have no idea why it is designed like this, but javap says so. return toVMTypeName(c); return c.getName().replace('.','/'); }
/** * Customizes a class file by replacing constant pools. * * @param templateClassName * The resource that contains the template class file. * @param replacements * A list of pair of strings that specify the substitution * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n } * * The search strings found in the constant pool will be replaced by the corresponding * replacement string. */ private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) { InputStream resource; if(CLASS_LOADER!=null) resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class"); else resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class"); if(resource==null) return null; return ClassTailor.tailor(resource,templateClassName,newClassName,replacements); }
public static byte[] tailor( Class templateClass, String newClassName, String... replacements ) { String vmname = toVMClassName(templateClass); return tailor( SecureLoader.getClassClassLoader(templateClass).getResourceAsStream(vmname+".class"), vmname, newClassName, replacements ); }
public static String toVMTypeName( Class c ) { if(c.isArray()) { // TODO: study how an array type is encoded. return '['+toVMTypeName(c.getComponentType()); } if(c.isPrimitive()) { if(c==Boolean.TYPE) return "Z"; if(c==Character.TYPE) return "C"; if(c==Byte.TYPE) return "B"; if(c==Double.TYPE) return "D"; if(c==Float.TYPE) return "F"; if(c==Integer.TYPE) return "I"; if(c==Long.TYPE) return "J"; if(c==Short.TYPE) return "S"; throw new IllegalArgumentException(c.getName()); } return 'L'+c.getName().replace('.','/')+';'; }
/** * Customizes a class file by replacing constant pools. * * @param templateClassName * The resource that contains the template class file. * @param replacements * A list of pair of strings that specify the substitution * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n } * * The search strings found in the constant pool will be replaced by the corresponding * replacement string. */ private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) { InputStream resource; if(CLASS_LOADER!=null) resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class"); else resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class"); if(resource==null) return null; return ClassTailor.tailor(resource,templateClassName,newClassName,replacements); }
/** * Returns the class name in the JVM format (such as "java/lang/String") */ public static String toVMClassName( Class c ) { assert !c.isPrimitive(); if(c.isArray()) // I have no idea why it is designed like this, but javap says so. return toVMTypeName(c); return c.getName().replace('.','/'); }
/** * Returns the class name in the JVM format (such as "java/lang/String") */ public static String toVMClassName( Class c ) { assert !c.isPrimitive(); if(c.isArray()) // I have no idea why it is designed like this, but javap says so. return toVMTypeName(c); return c.getName().replace('.','/'); }
public static String toVMTypeName( Class c ) { if(c.isArray()) { // TODO: study how an array type is encoded. return '['+toVMTypeName(c.getComponentType()); } if(c.isPrimitive()) { if(c==Boolean.TYPE) return "Z"; if(c==Character.TYPE) return "C"; if(c==Byte.TYPE) return "B"; if(c==Double.TYPE) return "D"; if(c==Float.TYPE) return "F"; if(c==Integer.TYPE) return "I"; if(c==Long.TYPE) return "J"; if(c==Short.TYPE) return "S"; throw new IllegalArgumentException(c.getName()); } return 'L'+c.getName().replace('.','/')+';'; }
public static String toVMTypeName( Class c ) { if(c.isArray()) { // TODO: study how an array type is encoded. return '['+toVMTypeName(c.getComponentType()); } if(c.isPrimitive()) { if(c==Boolean.TYPE) return "Z"; if(c==Character.TYPE) return "C"; if(c==Byte.TYPE) return "B"; if(c==Double.TYPE) return "D"; if(c==Float.TYPE) return "F"; if(c==Integer.TYPE) return "I"; if(c==Long.TYPE) return "J"; if(c==Short.TYPE) return "S"; throw new IllegalArgumentException(c.getName()); } return 'L'+c.getName().replace('.','/')+';'; }