1 package com.sun.org.apache.bcel.internal.verifier.statics; 2 3 56 57 import com.sun.org.apache.bcel.internal.classfile.*; 58 import com.sun.org.apache.bcel.internal.Repository; 59 import com.sun.org.apache.bcel.internal.verifier.*; 60 import com.sun.org.apache.bcel.internal.verifier.exc.*; 61 import com.sun.org.apache.bcel.internal.verifier.exc.Utility; 62 import java.util.ArrayList ; 63 64 74 public final class Pass1Verifier extends PassVerifier{ 75 79 private JavaClass jc; 80 81 84 private Verifier myOwner; 85 86 87 private JavaClass getJavaClass(){ 88 if (jc == null){ 89 jc = Repository.lookupClass(myOwner.getClassName()); 90 } 91 return jc; 92 } 93 94 99 public Pass1Verifier(Verifier owner){ 100 myOwner = owner; 101 } 102 103 161 public VerificationResult do_verify(){ 162 JavaClass jc; 163 try{ 164 jc = getJavaClass(); 166 if (jc != null){ 167 168 if (! myOwner.getClassName().equals(jc.getClassName())){ 169 throw new LoadingException("Wrong name: the internal name of the .class file '"+jc.getClassName()+"' does not match the file's name '"+myOwner.getClassName()+"'."); 172 } 173 } 174 175 } 176 catch(LoadingException e){ 177 return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage()); 178 } 179 catch(ClassFormatError e){ 180 return new VerificationResult(VerificationResult.VERIFIED_REJECTED, e.getMessage()); 182 } 183 catch(RuntimeException e){ 184 return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. "+e.getClass().getName()+" occured:\n"+Utility.getStackTrace(e)); 187 } 188 189 if (jc != null){ 190 return VerificationResult.VR_OK; 191 } 192 else{ 193 return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Repository.lookup() failed. FILE NOT FOUND?"); 196 } 197 } 198 199 209 public String [] getMessages(){ 210 return super.getMessages(); 212 } 213 214 } 215 | Popular Tags |