package jp.sourceforge.stigmata.digger;
-/*
- * $Id$
- */
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.List;
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.commons.EmptyVisitor;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
/**
*
*
*
* @author Haruaki TAMADA
- * @version $Revision$
*/
public class DefaultClassFileArchive implements ClassFileArchive{
private File file;
public DefaultClassFileArchive(File file){
this.file = file;
- parseClassName();
+ try{
+ parseClassName();
+ } catch(ParseClassNameFailedException e){
+ className = null;
+ }
}
public DefaultClassFileArchive(String file, String className){
try {
return file.toURI().toURL();
} catch (MalformedURLException ex) {
+ return null;
}
- return null;
}
public InputStream getInputStream(ClassFileEntry entry) throws IOException{
return className;
}
- private void parseClassName(){
+ private void parseClassName() throws ParseClassNameFailedException{
FileInputStream in = null;
try {
in = new FileInputStream(file);
this.className = visitor.getClassName();
} catch (FileNotFoundException ex) {
- ex.printStackTrace();
+ throw new ParseClassNameFailedException(ex);
} catch (IOException ex) {
- ex.printStackTrace();
+ throw new ParseClassNameFailedException(ex);
} finally{
if(in != null){
try{
in.close();
} catch(IOException e){
+ throw new ParseClassNameFailedException(e);
}
}
}
}
- private static class ClassNameExtractVisitor extends EmptyVisitor{
+ private static class ClassNameExtractVisitor extends ClassVisitor{
private String className;
+ public ClassNameExtractVisitor(){
+ super(Opcodes.ASM4);
+ }
+
public String getClassName(){
return className;
}
String superClassName, String[] interfaces){
className = name;
}
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String arg0, boolean arg1){
+ return null;
+ }
+
+ @Override
+ public void visitAttribute(Attribute arg0){
+ }
+
+ @Override
+ public void visitEnd(){
+ }
+
+ @Override
+ public FieldVisitor visitField(int arg0, String arg1, String arg2,
+ String arg3, Object arg4){
+ return null;
+ }
+
+ @Override
+ public void visitInnerClass(String arg0, String arg1, String arg2,
+ int arg3){
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int arg0, String arg1, String arg2,
+ String arg3, String[] arg4){
+ return null;
+ }
+
+ @Override
+ public void visitOuterClass(String arg0, String arg1, String arg2){
+ }
+
+ @Override
+ public void visitSource(String arg0, String arg1){
+
+ }
}
}