1149 * @throws ClassNotFoundException if class cannot be resolved 1150 */ 1151 public Class<?> findClass(final String fullName) throws ClassNotFoundException { 1152 if (fullName.indexOf('[') != -1 || fullName.indexOf('/') != -1) { 1153 // don't allow array class names or internal names. 1154 throw new ClassNotFoundException(fullName); 1155 } 1156 1157 // give chance to ClassFilter to filter out, if present 1158 if (classFilter != null && !classFilter.exposeToScripts(fullName)) { 1159 throw new ClassNotFoundException(fullName); 1160 } 1161 1162 // check package access as soon as possible! 1163 final SecurityManager sm = System.getSecurityManager(); 1164 if (sm != null) { 1165 checkPackageAccess(sm, fullName); 1166 } 1167 1168 // Try finding using the "app" loader. 1169 return Class.forName(fullName, true, appLoader); 1170 } 1171 1172 /** 1173 * Hook to print stack trace for a {@link Throwable} that occurred during 1174 * execution 1175 * 1176 * @param t throwable for which to dump stack 1177 */ 1178 public static void printStackTrace(final Throwable t) { 1179 if (Context.DEBUG) { 1180 t.printStackTrace(Context.getCurrentErr()); 1181 } 1182 } 1183 1184 /** 1185 * Verify generated bytecode before emission. This is called back from the 1186 * {@link ObjectClassGenerator} or the {@link Compiler}. If the "--verify-code" parameter 1187 * hasn't been given, this is a nop 1188 * 1189 * Note that verification may load classes -- we don't want to do that unless | 1149 * @throws ClassNotFoundException if class cannot be resolved 1150 */ 1151 public Class<?> findClass(final String fullName) throws ClassNotFoundException { 1152 if (fullName.indexOf('[') != -1 || fullName.indexOf('/') != -1) { 1153 // don't allow array class names or internal names. 1154 throw new ClassNotFoundException(fullName); 1155 } 1156 1157 // give chance to ClassFilter to filter out, if present 1158 if (classFilter != null && !classFilter.exposeToScripts(fullName)) { 1159 throw new ClassNotFoundException(fullName); 1160 } 1161 1162 // check package access as soon as possible! 1163 final SecurityManager sm = System.getSecurityManager(); 1164 if (sm != null) { 1165 checkPackageAccess(sm, fullName); 1166 } 1167 1168 // Try finding using the "app" loader. 1169 if (appLoader != null) { 1170 return Class.forName(fullName, true, appLoader); 1171 } else { 1172 final Class<?> cl = Class.forName(fullName); 1173 // return the Class only if it was loaded by boot loader 1174 if (cl.getClassLoader() == null) { 1175 return cl; 1176 } else { 1177 throw new ClassNotFoundException(fullName); 1178 } 1179 } 1180 } 1181 1182 /** 1183 * Hook to print stack trace for a {@link Throwable} that occurred during 1184 * execution 1185 * 1186 * @param t throwable for which to dump stack 1187 */ 1188 public static void printStackTrace(final Throwable t) { 1189 if (Context.DEBUG) { 1190 t.printStackTrace(Context.getCurrentErr()); 1191 } 1192 } 1193 1194 /** 1195 * Verify generated bytecode before emission. This is called back from the 1196 * {@link ObjectClassGenerator} or the {@link Compiler}. If the "--verify-code" parameter 1197 * hasn't been given, this is a nop 1198 * 1199 * Note that verification may load classes -- we don't want to do that unless |