74 // e.printStackTrace();
75 // }
76 if(image==null)
77 return null;
78 c = Injector.inject(cl,newClassName,image);
79 }
80 }
81 return c;
82 } catch(SecurityException e) {
83 // we don't have enough permission to do this
84 logger.log(Level.INFO,"Unable to create an optimized TransducedAccessor ",e);
85 return null;
86 }
87 }
88
89
90 /**
91 * Customizes a class file by replacing constant pools.
92 *
93 * @param templateClassName
94 * The resouce that contains the template class file.
95 * @param replacements
96 * A list of pair of strings that specify the substitution
97 * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n }
98 *
99 * The search strings found in the constant pool will be replaced by the corresponding
100 * replacement string.
101 */
102 private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) {
103 InputStream resource;
104 if(CLASS_LOADER!=null)
105 resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class");
106 else
107 resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class");
108 if(resource==null)
109 return null;
110
111 return ClassTailor.tailor(resource,templateClassName,newClassName,replacements);
112 }
113
114 private static final ClassLoader CLASS_LOADER = SecureLoader.getClassClassLoader(AccessorInjector.class);
|
74 // e.printStackTrace();
75 // }
76 if(image==null)
77 return null;
78 c = Injector.inject(cl,newClassName,image);
79 }
80 }
81 return c;
82 } catch(SecurityException e) {
83 // we don't have enough permission to do this
84 logger.log(Level.INFO,"Unable to create an optimized TransducedAccessor ",e);
85 return null;
86 }
87 }
88
89
90 /**
91 * Customizes a class file by replacing constant pools.
92 *
93 * @param templateClassName
94 * The resource that contains the template class file.
95 * @param replacements
96 * A list of pair of strings that specify the substitution
97 * {@code String[]{search_0, replace_0, search_1, replace_1, ..., search_n, replace_n }
98 *
99 * The search strings found in the constant pool will be replaced by the corresponding
100 * replacement string.
101 */
102 private static byte[] tailor( String templateClassName, String newClassName, String... replacements ) {
103 InputStream resource;
104 if(CLASS_LOADER!=null)
105 resource = CLASS_LOADER.getResourceAsStream(templateClassName+".class");
106 else
107 resource = ClassLoader.getSystemResourceAsStream(templateClassName+".class");
108 if(resource==null)
109 return null;
110
111 return ClassTailor.tailor(resource,templateClassName,newClassName,replacements);
112 }
113
114 private static final ClassLoader CLASS_LOADER = SecureLoader.getClassClassLoader(AccessorInjector.class);
|