1 23 24 29 30 package com.sun.enterprise.tools.verifier.apiscan.classfile; 31 32 import java.io.IOException ; 33 import java.io.InputStream ; 34 import java.util.logging.Logger ; 35 36 import com.sun.org.apache.bcel.internal.util.ClassPath; 37 38 49 class BCELClassFileLoader1 implements ClassFileLoader { 50 51 private static String resourceBundleName = "com.sun.enterprise.tools.verifier.apiscan.LocalStrings"; 52 private static Logger logger = Logger.getLogger("apiscan.classfile", resourceBundleName); private ClassPath cp; 54 55 65 public BCELClassFileLoader1(String classPath) { 66 logger.entering("BCELClassFileLoader1", "<init>(String)", classPath); cp = new ClassPath(classPath); 68 } 69 70 public ClassFile load(String externalClassName) throws IOException { 72 logger.entering("BCELClassFileLoader1", "load", externalClassName); String internalClassName = externalClassName.replace('.', '/'); 75 InputStream is = cp.getClassFile(internalClassName, ".class") .getInputStream(); 80 try { 81 ClassFile cf = new BCELClassFile(is, internalClassName + ".class"); matchClassSignature(cf, externalClassName); 83 return cf; 84 } finally { 85 is.close(); 86 } 87 } 88 89 private void matchClassSignature(ClassFile cf, String externalClassName) 94 throws IOException { 95 String nameOfLoadedClass = cf.getName(); 96 if (!nameOfLoadedClass.equals(externalClassName)) { 97 throw new IOException ( 98 externalClassName + ".class represents " + 99 cf.getName() + 100 ". Perhaps your package name is incorrect or you passed the" + 101 " name using internal form instead of using external form."); 102 } 103 } 104 } 105 | Popular Tags |