LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Tue Feb 26 00:29:33 CET 2008
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/08/02 26:00:29

    Modified: jop/java/tools/src/com/jopdesign/libgraph/struct/bcel
    BcelClassLoader.java BcelConstantPoolInfo.java
    BcelMethodCode.java BcelClassInfo.java
    Log:
    fixes for incomplete code loading, added more array handling code


    Revision Changes Path
    1.2 jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelClassLoader.java

    http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelClassLoader.java.diff?r1=1.1&r2=1.2

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: BcelClassLoader.java
    ===================================================================
    RCS file: /cvsroot/stefant/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelClassLoader.java,v
    retrieving revision 1.1
    retrieving revision 1.2
    diff -u -b -r1.1 -r1.2
    --- BcelClassLoader.java 15 Feb 2008 21:08:19 -0000 1.1
    +++ BcelClassLoader.java 25 Feb 2008 23:29:33 -0000 1.2
    @@ -90,7 +90,9 @@
    */
    public JavaClass createJavaClass(String className) throws IOException {
    InputStream is = classPath.getInputStream(className);
    - return new ClassParser(is, className).parse();
    + JavaClass javaClass = new ClassParser(is, className).parse();
    + is.close();
    + return javaClass;
    }

    }



    1.2 jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelConstantPoolInfo.java

    http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelConstantPoolInfo.java.diff?r1=1.1&r2=1.2

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: BcelConstantPoolInfo.java
    ===================================================================
    RCS file: /cvsroot/stefant/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelConstantPoolInfo.java,v
    retrieving revision 1.1
    retrieving revision 1.2
    diff -u -b -r1.1 -r1.2
    --- BcelConstantPoolInfo.java 13 Jan 2008 20:29:32 -0000 1.1
    +++ BcelConstantPoolInfo.java 25 Feb 2008 23:29:33 -0000 1.2
    @@ -18,13 +18,25 @@
    */
    package com.jopdesign.libgraph.struct.bcel;

    -import com.jopdesign.libgraph.struct.*;
    import com.jopdesign.libgraph.struct.ConstantClass;
    +import com.jopdesign.libgraph.struct.ConstantField;
    +import com.jopdesign.libgraph.struct.ConstantMethod;
    +import com.jopdesign.libgraph.struct.ConstantPoolInfo;
    import com.jopdesign.libgraph.struct.ConstantValue;
    +import com.jopdesign.libgraph.struct.TypeException;
    import com.jopdesign.libgraph.struct.type.StringType;
    import com.jopdesign.libgraph.struct.type.TypeInfo;
    import org.apache.bcel.Constants;
    -import org.apache.bcel.classfile.*;
    +import org.apache.bcel.classfile.Constant;
    +import org.apache.bcel.classfile.ConstantCP;
    +import org.apache.bcel.classfile.ConstantDouble;
    +import org.apache.bcel.classfile.ConstantFloat;
    +import org.apache.bcel.classfile.ConstantInteger;
    +import org.apache.bcel.classfile.ConstantLong;
    +import org.apache.bcel.classfile.ConstantNameAndType;
    +import org.apache.bcel.classfile.ConstantPool;
    +import org.apache.bcel.classfile.ConstantString;
    +import org.apache.bcel.classfile.ConstantUtf8;
    import org.apache.bcel.generic.ConstantPoolGen;

    /**
    @@ -76,61 +88,37 @@
    (org.apache.bcel.classfile.ConstantClass)cp.getConstant(pos);

    String className = ((ConstantUtf8)cp.getConstant(cmr.getNameIndex())).getBytes().replace('/','.');
    - ClassInfo classInfo = loadClassInfo(className);

    - if ( classInfo == null ) {
    - return new ConstantClass(className);
    + return getAppStruct().getConstantClass(className, false);
    }

    - return new ConstantClass(classInfo);
    - }
    -
    - public ConstantMethod getMethodReference(int pos) throws TypeException {
    + public ConstantMethod getMethodReference(int pos, boolean isStatic) throws TypeException {
    ConstantPool cp = cpg.getConstantPool();
    ConstantCP cmr = (ConstantCP)cp.getConstant(pos);
    ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
    +
    String signature = ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes();
    String name = ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes();
    String className = getClassName(cp, cmr); - ClassInfo classInfo = loadClassInfo(className); - - if ( classInfo == null ) { - return new ConstantMethod(className, name, signature, - cmr.getTag() == Constants.CONSTANT_InterfaceMethodref); - } + boolean isInterface = cmr.getTag() == Constants.CONSTANT_InterfaceMethodref; - MethodInfo methodInfo = classInfo.getVirtualMethodInfo(name, signature); - if ( methodInfo == null ) { - // Hu, method not found, although classes are fully loaded! - throw new TypeException("Could not find method {"+name+"} by signature {" + - signature + "} in class {" + className + "}"); + ConstantClass cClass = getAppStruct().getConstantClass(className, isInterface); + return getAppStruct().getConstantMethod(cClass, name, signature, isStatic); } - return new ConstantMethod(classInfo, methodInfo); - } - - public ConstantField getFieldReference(int pos) throws TypeException { + public ConstantField getFieldReference(int pos, boolean isStatic) throws TypeException { ConstantPool cp = cpg.getConstantPool(); ConstantCP cmr = (ConstantCP)cp.getConstant(pos); ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex()); - String name = ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes(); - - String className = getClassName(cp, cmr); - ClassInfo classInfo = loadClassInfo(className); - if ( classInfo == null ) { - // if classInfo is null, create emtpy fieldInfo with strings as className and types. + String name = ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes(); String signature = ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes(); - return new ConstantField(className, name, signature); - } - FieldInfo fieldInfo = classInfo.getVirtualFieldInfo(name); - if ( fieldInfo == null ) { - throw new TypeException("Could not find field {"+name+"} in class {"+classInfo.getClassName()+"}"); - } + String className = getClassName(cp, cmr); - return new ConstantField(classInfo, fieldInfo); + ConstantClass cClass = getAppStruct().getConstantClass(className, false); + return getAppStruct().getConstantField(cClass, name, signature, isStatic); } @@ -183,13 +171,4 @@ org.apache.bcel.Constants.CONSTANT_Class).replace('/', '.'); } - protected ClassInfo loadClassInfo(String className) throws TypeException { - - ClassInfo classInfo = getAppStruct().getClassInfo(className); - if ( classInfo == null ) { - classInfo = getAppStruct().tryLoadMissingClass(className); - } - - return classInfo; - } } 1.4 jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelMethodCode.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelMethodCode.java.diff?r1=1.3&r2=1.4 (In the diff below, changes in quantity of whitespace are not shown.) Index: BcelMethodCode.java =================================================================== RCS file: /cvsroot/stefant/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelMethodCode.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- BcelMethodCode.java 15 Feb 2008 00:41:20 -0000 1.3 +++ BcelMethodCode.java 25 Feb 2008 23:29:33 -0000 1.4 @@ -126,7 +126,7 @@ return graph; } - public void compileGraph(ControlFlowGraph graph) throws GraphException { + protected void compileGraph(ControlFlowGraph graph) throws GraphException { ConstantPoolGen cpg = methodInfo.getConstantPoolGen(); 1.5 jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelClassInfo.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelClassInfo.java.diff?r1=1.4&r2=1.5 (In the diff below, changes in quantity of whitespace are not shown.) Index: BcelClassInfo.java =================================================================== RCS file: /cvsroot/stefant/jop/java/tools/src/com/jopdesign/libgraph/struct/bcel/BcelClassInfo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- BcelClassInfo.java 15 Feb 2008 21:08:19 -0000 1.4 +++ BcelClassInfo.java 25 Feb 2008 23:29:33 -0000 1.5 @@ -35,6 +35,7 @@ import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.ArrayType; import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.ObjectType; @@ -114,27 +115,25 @@ addClass(className); if(method) { - Type type = Type.getReturnType(signature); - - if(type instanceof ObjectType) { - addClass(((ObjectType)type).getClassName()); - } + addType( Type.getReturnType(signature) ); Type[] types = Type.getArgumentTypes(signature); for(int i = 0; i < types.length; i++) { - type = types[i]; - if(type instanceof ObjectType) { - addClass(((ObjectType)type).getClassName()); - } + addType( types[i] ); } } else { - Type type = Type.getType(signature); - if(type instanceof ObjectType) { - addClass(((ObjectType)type).getClassName()); + addType( Type.getType(signature) ); } + } + private void addType(Type type) { + if ( type instanceof ObjectType ) { + addClass(((ObjectType)type).getClassName()); + } else if ( type instanceof ArrayType ) { + addType(((ArrayType)type).getElementType()); + } } private void addClass(String className) { @@ -190,15 +189,19 @@ return javaClass; } - protected Set loadInterfaces() { + protected Set loadInterfaces() throws TypeException { String[] names = javaClass.getInterfaceNames(); Set interfaces = new HashSet(names.length); for (int i = 0; i < names.length; i++) { String name = names[i]; - ClassInfo cls = getAppStruct().getClassInfo(name); + ClassInfo cls = getAppStruct().getClassInfo(name, true); if ( cls == null ) { - logger.error("Could not find interface class {"+name+"} for class {" + getClassName() + "}" ); + // TODO set interface as ConstantClass, set class to 'incomplete' state (errors are thrown by getClassInfo) + + if (logger.isInfoEnabled()) { + logger.info("Could not find interface class {" + name + "} for class {" + getClassName() + "}"); + } } else { interfaces.add(cls); }

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.