xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam GoldenInvokable.java JamTestBase.java ParserJamTest.java
Date Wed, 03 Mar 2004 00:01:43 GMT
pcal        2004/03/02 16:01:43

  Modified:    v2/src/jam java.g
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable EClass.java
                        EParameter.java EService.java EServiceFactory.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl
                        EAnnotationDefinitionImpl.java EClassImpl.java
                        EInvokableImpl.java EMethodImpl.java
                        EParameterImpl.java EServiceImpl.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/ref
                        UnqualifiedJClassRef.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal
                        ArrayJClass.java BaseJClassLoader.java
                        JClassLoaderImpl.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal/javadoc
                        JDClassLoader.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal/parser
                        ParserClassBuilder.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/provider
                        NewJServiceFactory.java ReflectionClassBuilder.java
               v2/test/src/jamtest build.xml
               v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
                        GoldenInvokable.java JamTestBase.java
                        ParserJamTest.java
  Added:       v2/src/jam/org/apache/xmlbeans/impl/jam/internal/parser
                        ParamStruct.java ParamStructPool.java
  Log:
  jam: more fixes and test cases
  
  Revision  Changes    Path
  1.7       +16 -21    xml-xmlbeans/v2/src/jam/java.g
  
  Index: java.g
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/java.g,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- java.g	2 Mar 2004 22:03:04 -0000	1.6
  +++ java.g	3 Mar 2004 00:01:42 -0000	1.7
  @@ -17,6 +17,7 @@
   package org.apache.xmlbeans.impl.jam.internal.parser.generated;
   
   import org.apache.xmlbeans.impl.jam.*;
  +import org.apache.xmlbeans.impl.jam.internal.parser.ParamStructPool;
   import org.apache.xmlbeans.impl.jam.editable.*;
   import org.apache.xmlbeans.impl.jam.editable.impl.*;
   import java.util.*;
  @@ -175,7 +176,7 @@
     private List mImports = new ArrayList();
     private List mClasses = new ArrayList();
   
  -  private List mParamList = new ArrayList();
  +  //private ParamStructPool mParamPool = new ParamStructPool();
     private List mExceptionList = new ArrayList();
     private JClassLoader mLoader = null;
   
  @@ -236,8 +237,10 @@
   
       private EClass newClass(String simpleName) {
       //FIXME more to do here
  -      //EClass clazz = mResult.addNewClass(mPackage,simpleName/*,mImports*/);
  -      EClass clazz = new EClassImpl(mPackage,simpleName,mLoader);
  +      //EClass clazz = mResult.addNewClass(mPackage,simpleName,mImports);
  +      String[] importSpecs = new String[mImports.size()];
  +      mImports.toArray(importSpecs);
  +      EClass clazz = new EClassImpl(mPackage,simpleName,mLoader,importSpecs);
         mClasses.add(clazz);
         return clazz;
       }
  @@ -347,9 +350,9 @@
   
   constructor[EClass clazz, int modifiers, String name]
   {
  -  List params = new ArrayList(); //FIXME try reuse this please
  +  ParamStructPool pool = new ParamStructPool();
   }
  -  : (LPAREN (parameterList[params])? RPAREN (throwsClause[mExceptionList])? statement_block)
  +  : (LPAREN (parameterList[pool])? RPAREN (throwsClause[mExceptionList])? statement_block)
   {
     if (!name.equals(clazz.getSimpleName())) {
       throw new IllegalArgumentException("FIXME not a constructor '"+
  @@ -357,8 +360,7 @@
     }
     EConstructorImpl constr = (EConstructorImpl)clazz.addNewConstructor();
     constr.setModifiers(modifiers);
  -  System.out.println("============== Setting params "+params.size());
  -  constr.setParameters(params);
  +  pool.setParametersOn(constr);
     constr.setUnqualifiedThrows(mExceptionList);
     applyJavadocs(constr);
   
  @@ -383,16 +385,15 @@
   	  )
   	  |
   	  (
  -	  { List params = new ArrayList();  //FIXME can we reuse this please?
  +	  { ParamStructPool pool = new ParamStructPool();  //FIXME can we reuse this please?
   	  }
  -      (LPAREN (parameterList[params])? RPAREN tweener (throwsClause[mExceptionList])? (statement_block
| SEMI)) {
  +      (LPAREN (parameterList[pool])? RPAREN tweener (throwsClause[mExceptionList])? (statement_block
| SEMI)) {
           if (VERBOSE) System.out.println("creating method "+name);
           EMethodImpl method = (EMethodImpl)clazz.addNewMethod();
           method.setSimpleName(name);
           method.setUnqualifiedReturnType(type);
           method.setModifiers(modifiers);
  -        System.out.println("============== Setting params "+params.size());
  -        method.setParameters(mParamList);
  +        pool.setParametersOn(method);
           method.setUnqualifiedThrows(mExceptionList);
           applyJavadocs(method);
         }
  @@ -425,24 +426,18 @@
   
   
   // A list of formal parameters
  -parameterList[Collection list] {}
  -	:	(parameter[list] (COMMA parameter[list])*)
  +parameterList[ParamStructPool pool]
  +	:	(parameter[pool] (COMMA parameter[pool])*)
   ;
   
   // A formal parameter.
  -parameter[Collection list]
  +parameter[ParamStructPool pool]
   {
     String type;
     String name;
   }
   : tweener ("final")? t:IDENT tweener n:IDENT tweener {
  -
  -  EParameterImpl param = new EParameterImpl();
  -  param.setUnqualifiedType(t.getText());
  -  param.setSimpleName(n.getText());
  -  list.add(param);
  -  System.out.println("\n\n\nadded to list!! "+list.size()+"\n\n\n");
  -
  +  pool.add(t.getText(),n.getText());
   }
   ;
   
  
  
  
  1.6       +0 -11     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EClass.java
  
  Index: EClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EClass.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EClass.java	2 Mar 2004 04:26:18 -0000	1.5
  +++ EClass.java	3 Mar 2004 00:01:42 -0000	1.6
  @@ -156,17 +156,6 @@
      */
     public EMethod[] getEditableMethods();
   
  -  /**
  -   * Adds an import specification the the class.  This should be everything
  -   * between 'import ' and ';'.  Wildcard '*' imports are valid.
  -   */
  -  public void addImportSpec(String spec);
  -
  -  /**
  -   * Calls addImportSpec(String) for each String in the given Collection.
  -   */
  -  public void addImportSpecs(Collection c);
  -
   
   
     // not sure that these are something we want to do.  is a property really
  
  
  
  1.3       +2 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EParameter.java
  
  Index: EParameter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EParameter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EParameter.java	12 Feb 2004 20:06:11 -0000	1.2
  +++ EParameter.java	3 Mar 2004 00:01:42 -0000	1.3
  @@ -27,4 +27,6 @@
     public void setType(String typeName);
   
     public void setType(JClass type);
  +
  +  public void setUnqualifiedType(String ucname);
   }
  
  
  
  1.5       +3 -1      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EService.java
  
  Index: EService.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EService.java	2 Mar 2004 06:32:13 -0000	1.4
  +++ EService.java	3 Mar 2004 00:01:42 -0000	1.5
  @@ -24,7 +24,9 @@
    */
   public interface EService extends JService {
   
  -  public EClass addNewClass(String packageName, String className);
  +  public EClass addNewClass(String packageName,
  +                            String className,
  +                            String[] importSpecs);
   
     public EClass addNewClass(JClass copyme);
   }
  
  
  
  1.7       +2 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EServiceFactory.java
  
  Index: EServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/EServiceFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EServiceFactory.java	2 Mar 2004 06:32:13 -0000	1.6
  +++ EServiceFactory.java	3 Mar 2004 00:01:42 -0000	1.7
  @@ -75,8 +75,8 @@
         //
         //dumb test code
         //
  -      EClass testClass = service.addNewClass("com.bea.pcal","TestClass");
  -      EClass fooClass = service.addNewClass("com.bea.pcal","Foo");
  +      EClass testClass = service.addNewClass("com.bea.pcal","TestClass",null);
  +      EClass fooClass = service.addNewClass("com.bea.pcal","Foo",null);
         testClass.addNewMethod().setReturnType(fooClass);
         testClass.addNewField().setUnqualifiedType("TestClass");
         //
  
  
  
  1.2       +5 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EAnnotationDefinitionImpl.java
  
  Index: EAnnotationDefinitionImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EAnnotationDefinitionImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EAnnotationDefinitionImpl.java	1 Mar 2004 00:10:18 -0000	1.1
  +++ EAnnotationDefinitionImpl.java	3 Mar 2004 00:01:42 -0000	1.2
  @@ -20,6 +20,8 @@
   import org.apache.xmlbeans.impl.jam.JAnnotationMemberDefinition;
   import org.apache.xmlbeans.impl.jam.JClassLoader;
   
  +import java.util.List;
  +
   /**
    *
    * @author Patrick Calahan <pcal@bea.com>
  @@ -32,8 +34,9 @@
   
     public EAnnotationDefinitionImpl(String packageName,
                                      String simpleName,
  -                                   JClassLoader classLoader) {
  -    super(packageName,simpleName,classLoader);
  +                                   JClassLoader classLoader,
  +                                   String[] importSpecs) {
  +    super(packageName,simpleName,classLoader,importSpecs);
     }
   
     // ========================================================================
  
  
  
  1.7       +5 -18     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java
  
  Index: EClassImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EClassImpl.java	2 Mar 2004 22:03:04 -0000	1.6
  +++ EClassImpl.java	3 Mar 2004 00:01:42 -0000	1.7
  @@ -51,7 +51,7 @@
     // are we an interface or a class?
     private boolean mIsInterface = false;
   
  -  private List mImports = null;
  +  private String[] mImports = null;
   
     // FIXME implement this - we should only create one UnqualifiedJClassRef
     // for each unqualified name so as to avoid resolving them over and over.
  @@ -62,9 +62,11 @@
   
     public EClassImpl(String packageName,
                       String simpleName,
  -                    JClassLoader classLoader) {
  +                    JClassLoader classLoader,
  +                    String[] importSpecs) {
       super(simpleName,classLoader);
       mPackageName = packageName;
  +    mImports = importSpecs;
     }
   
     // ========================================================================
  @@ -319,19 +321,6 @@
       return out;
     }
   
  -  public void addImportSpec(String spec) {
  -    if (spec == null) throw new IllegalArgumentException("null spec");
  -    if (mImports == null) mImports = new ArrayList();
  -    mImports.add(spec);
  -  }
  -
  -  public void addImportSpecs(Collection c) {
  -    if (c == null) throw new IllegalArgumentException("null collection");
  -    for(Iterator i = c.iterator(); i.hasNext(); ) {
  -      addImportSpec((String)i.next());
  -    }
  -  }
  -
     public void setIsInterface(boolean b) {
       mIsInterface = b;
     }
  @@ -361,9 +350,7 @@
   
     public String[] getImportSpecs() {
       if (mImports == null) return new String[0];
  -    String[] out = new String[mImports.size()];
  -    mImports.toArray(out);
  -    return out;
  +    return mImports;
     }
   
     // ========================================================================
  
  
  
  1.5       +6 -18     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java
  
  Index: EInvokableImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EInvokableImpl.java	2 Mar 2004 22:03:04 -0000	1.4
  +++ EInvokableImpl.java	3 Mar 2004 00:01:42 -0000	1.5
  @@ -148,29 +148,17 @@
     // ========================================================================
     // Other public methods
   
  -  /**
  -   * This is only intended for use by the parser.  The list must contain
  -   * EParameterImpls.
  -   */
  -  public void setParameters(List paramList) {
  -    System.out.println("\n\n\n\nSET PARAMETER LIST "+paramList.size());
  -    if (paramList == null || paramList.size() == 0) {
  -      mParameters = null;
  -      return;
  -    }
  -    mParameters = new ArrayList(paramList.size());
  -    mParameters.addAll(paramList);
  -    for(int i=0; i<mParameters.size(); i++) {
  -      ((EParameterImpl)mParameters.get(i)).setContainingMember(this);
  -    }
  -  }
  -
  +  //FIXME this is here only so the parser can be lazy - please remove it
     public void setUnqualifiedThrows(List classnames) {
       if (classnames == null || classnames.size() == 0) {
         mExceptionClassRefs= null;
         return;
       }
       mExceptionClassRefs = new ArrayList(classnames.size());
  -    mExceptionClassRefs.addAll(classnames); //FIXME
  +    for(int i=0; i<classnames.size(); i++) {
  +      mExceptionClassRefs.add(UnqualifiedJClassRef.create
  +                              ((String)classnames.get(i),
  +                               (EClassImpl)getContainingClass()));
  +    }
     }
   }
  
  
  
  1.4       +12 -6     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EMethodImpl.java
  
  Index: EMethodImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EMethodImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EMethodImpl.java	25 Feb 2004 18:56:49 -0000	1.3
  +++ EMethodImpl.java	3 Mar 2004 00:01:42 -0000	1.4
  @@ -16,6 +16,10 @@
   package org.apache.xmlbeans.impl.jam.editable.impl;
   
   import org.apache.xmlbeans.impl.jam.editable.EMethod;
  +import org.apache.xmlbeans.impl.jam.editable.impl.ref.UnqualifiedJClassRef;
  +import org.apache.xmlbeans.impl.jam.editable.impl.ref.JClassRef;
  +import org.apache.xmlbeans.impl.jam.editable.impl.ref.QualifiedJClassRef;
  +import org.apache.xmlbeans.impl.jam.editable.impl.ref.DirectJClassRef;
   import org.apache.xmlbeans.impl.jam.JClass;
   import org.apache.xmlbeans.impl.jam.internal.VoidJClass;
   
  @@ -34,7 +38,7 @@
     // ========================================================================
     // Variables
   
  -  private String mReturnTypeName = null;
  +  private JClassRef mReturnTypeRef = null;
   
     // ========================================================================
     // Constructors
  @@ -47,25 +51,27 @@
     // EMethod implementation
   
     public void setReturnType(String className) {
  -    mReturnTypeName = className;
  +    mReturnTypeRef = QualifiedJClassRef.create
  +            (className,(EClassImpl)getContainingClass());
     }
   
     public void setUnqualifiedReturnType(String unqualifiedTypeName) {
  -    mReturnTypeName = unqualifiedTypeName; //FIXME
  +    mReturnTypeRef = UnqualifiedJClassRef.create
  +            (unqualifiedTypeName,(EClassImpl)getContainingClass());
     }
   
     public void setReturnType(JClass c) {
  -    setReturnType(c.getQualifiedName());
  +    mReturnTypeRef = DirectJClassRef.create(c);
     }
   
     // ========================================================================
     // JMethod implementation
   
     public JClass getReturnType() {
  -    if (mReturnTypeName == null) {
  +    if (mReturnTypeRef == null) {
         return VoidJClass.getInstance();
       } else {
  -      return getClassLoader().loadClass(mReturnTypeName);
  +      return mReturnTypeRef.getRefClass();
       }
     }
   
  
  
  
  1.5       +0 -10     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EParameterImpl.java
  
  Index: EParameterImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EParameterImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- EParameterImpl.java	2 Mar 2004 22:03:04 -0000	1.4
  +++ EParameterImpl.java	3 Mar 2004 00:01:42 -0000	1.5
  @@ -37,9 +37,6 @@
     // ========================================================================
     // Constructors
   
  -  // be careful with this one, should really only be used by the parser
  -  public EParameterImpl() {}
  -
     public EParameterImpl(String simpleName,
                           EMemberImpl containingMember,
                           String typeName)
  @@ -82,11 +79,4 @@
       return mTypeClassRef.getRefClass();
     }
   
  -  // ========================================================================
  -  // Package methods
  -
  -  /*package*/ void setContainingMember(EMemberImpl member) {
  -    System.out.println("\n\n\n\nSSET CONTAINING MEMBER "+member);
  -    super.setContainingClass((EClassImpl)member.getContainingClass());
  -  }
   }
  
  
  
  1.6       +4 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EServiceImpl.java
  
  Index: EServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EServiceImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EServiceImpl.java	2 Mar 2004 06:32:13 -0000	1.5
  +++ EServiceImpl.java	3 Mar 2004 00:01:42 -0000	1.6
  @@ -48,8 +48,10 @@
     // ========================================================================
     // EService implementation
   
  -  public EClass addNewClass(String packageName, String className) {
  -    EClassImpl out = new EClassImpl(packageName,className,this);
  +  public EClass addNewClass(String packageName,
  +                            String className,
  +                            String[] importSpecs) {
  +    EClassImpl out = new EClassImpl(packageName,className,this,importSpecs);
       System.out.println("---= adding '"+out.getQualifiedName()+"'");
       mClasses.put(out.getQualifiedName(),out);
       return out;
  
  
  
  1.4       +75 -22    xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/ref/UnqualifiedJClassRef.java
  
  Index: UnqualifiedJClassRef.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/ref/UnqualifiedJClassRef.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnqualifiedJClassRef.java	2 Mar 2004 22:03:04 -0000	1.3
  +++ UnqualifiedJClassRef.java	3 Mar 2004 00:01:42 -0000	1.4
  @@ -16,6 +16,8 @@
   
   import org.apache.xmlbeans.impl.jam.JClass;
   
  +import java.io.StringWriter;
  +
   /**
    *
    * @author Patrick Calahan <pcal@bea.com>
  @@ -25,7 +27,8 @@
     // ========================================================================
     // Constants
   
  -  private static final boolean VERBOSE = true;
  +  private static final boolean VERBOSE = false;
  +  private static final String PREFIX = "[UnqualifiedJClassRef]";
   
     // ========================================================================
     // Variables
  @@ -55,7 +58,8 @@
       if (ucname == null) throw new IllegalArgumentException("null ucname");
       mContext = ctx;
       mUnqualifiedClassname = ucname;
  -    if (VERBOSE) System.out.println("[UnqualifiedJClassRef] "+ucname);
  +    if (VERBOSE) System.out.println("[UnqualifiedJClassRef] created for '"+
  +                                    ucname+"'");
     }
   
     // ========================================================================
  @@ -68,28 +72,75 @@
   
     public String getQualifiedName() {
       if (mQualifiedClassname != null) return mQualifiedClassname;
  -    mQualifiedClassname = checkExplicitImport();
  -    if (mQualifiedClassname != null) return mQualifiedClassname;
  -    mQualifiedClassname = checkSamePackage();
  -    if (mQualifiedClassname != null) return mQualifiedClassname;
  -    mQualifiedClassname = checkAlreadyQualified();
  -    if (mQualifiedClassname != null) return mQualifiedClassname;
  -    //FIXME '*' imports!
  -    throw new IllegalStateException("unable to handle unqualified java type "+
  -                                    "reference '"+mUnqualifiedClassname+"'. "+
  -                                    "This is still partially NYI.");
  +    // ok, check to see if it's an array type.  if so, we want to strip
  +    // away all the brackets and so we can try to load just the component
  +    // type.
  +    String candidateName;
  +    int arrayDimensions = 0;
  +    int bracket = mUnqualifiedClassname.indexOf('[');
  +    if (bracket != -1) {
  +      candidateName = mUnqualifiedClassname.substring(0,bracket);
  +      do {
  +        arrayDimensions++;
  +        bracket = mUnqualifiedClassname.indexOf('[',bracket+1);
  +      } while(bracket != -1);
  +    } else {
  +      candidateName = mUnqualifiedClassname;
  +    }
  +    // ok, try to get the class that they are talking about
  +    String name = qualifyName(candidateName);
  +    if (name == null) {
  +      throw new IllegalStateException("unable to handle unqualified java type "+
  +                                      "reference '"+candidateName+" ["+
  +                                      mUnqualifiedClassname+"]'. "+
  +                                      "This is still partially NYI.");
  +    }
  +    // now if it was an array, we need to convert it into a corresponding
  +    // field descriptor
  +    if (arrayDimensions > 0) {
  +      StringWriter out = new StringWriter();
  +      for(int i=0; i<arrayDimensions; i++) out.write('[');
  +      out.write('L');
  +      out.write(name);
  +      out.write(';');
  +
  +      mQualifiedClassname = out.toString();
  +    } else {
  +      mQualifiedClassname = name;
  +    }
  +    return mQualifiedClassname;
     }
   
     // ========================================================================
     // Private methods
   
  +  private String qualifyName(String ucname) {
  +    String out = null;
  +    if ((out = checkExplicitImport(ucname)) != null) return out;
  +    if ((out = checkJavaLang(ucname)) != null) return out;
  +    if ((out = checkSamePackage(ucname)) != null) return out;
  +    if ((out = checkAlreadyQualified(ucname)) != null) return out;
  +    return null;
  +  }
  +
     /**
      * Check to see if the unqualified name actually is already qualified.
      */
  -  private String checkSamePackage() {
  -    String name = mContext.getPackageName()+"."+mUnqualifiedClassname;
  +  private String checkSamePackage(String ucname) {
  +    String name = mContext.getPackageName()+"."+ucname;
  +    JClass clazz = mContext.getClassLoader().loadClass(name);
  +    if (VERBOSE) System.out.println(PREFIX+" checkSamePackage '"+name+"'  "+
  +                                    clazz.isUnresolved()+"  "+mContext.getClassLoader().getClass());
  +    return (clazz.isUnresolved()) ? null : clazz.getQualifiedName();
  +  }
  +
  +  /**
  +   * Check to see if the unqualified name is in java.lang.
  +   */
  +  private String checkJavaLang(String ucname) {
  +    String name = "java.lang."+ucname;
       JClass clazz = mContext.getClassLoader().loadClass(name);
  -    if (VERBOSE) System.out.println("checkSamePackage '"+name+"'  "+
  +    if (VERBOSE) System.out.println(PREFIX+" checkJavaLang '"+name+"'  "+
                                       clazz.isUnresolved()+"  "+mContext.getClassLoader().getClass());
       return (clazz.isUnresolved()) ? null : clazz.getQualifiedName();
     }
  @@ -97,9 +148,9 @@
     /**
      * Check to see if the unqualified name actually is already qualified.
      */
  -  private String checkAlreadyQualified() {
  +  private String checkAlreadyQualified(String ucname) {
       JClass clazz =
  -            mContext.getClassLoader().loadClass(mUnqualifiedClassname);
  +            mContext.getClassLoader().loadClass(ucname);
       return (clazz.isUnresolved()) ? null : clazz.getQualifiedName();
     }
   
  @@ -108,14 +159,16 @@
      * Run through the list of import specs and see if the class was explicitly
      * (i.e. without '*') imported.
      */
  -  private String checkExplicitImport() {
  +  private String checkExplicitImport(String ucname) {
       String[] imports = mContext.getImportSpecs();
  +    if (VERBOSE) System.out.println(PREFIX+" checkExplicitImport "+
  +                                    imports.length);
       for(int i=0; i<imports.length; i++) {
         //FIXME this does not cover inner classes
  -      String impo = lastSegment(imports[i]);
  -      if (imports[i].equals(mUnqualifiedClassname)) {
  -        return imports[i];
  -      }
  +      String last = lastSegment(imports[i]);
  +      if (VERBOSE) System.out.println(PREFIX+" checkExplicitImport '"+
  +                                      imports[i]+"'  '"+last+"'");
  +      if (last.equals(ucname)) return imports[i];
       }
       return null;
     }
  
  
  
  1.4       +24 -20    xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/ArrayJClass.java
  
  Index: ArrayJClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/ArrayJClass.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArrayJClass.java	12 Feb 2004 20:06:15 -0000	1.3
  +++ ArrayJClass.java	3 Mar 2004 00:01:42 -0000	1.4
  @@ -54,10 +54,14 @@
     // ========================================================================
     // Factory methods
   
  -  public static JClass createClassFor(String arrayFD, JClassLoader loader) 
  +  /**
  +   * Creates an array JClass from a field descriptor as described in the JLS.
  +   * This is the nasty '[[[Lfoo.bar.Baz;'-style notation.
  +   */
  +  public static JClass createClassForFD(String arrayFD, JClassLoader loader)
     {
       if (!arrayFD.startsWith("[")) {
  -      throw new IllegalArgumentException("must be an array type: "+arrayFD);
  +      throw new IllegalArgumentException("must be an array type fd: "+arrayFD);
       }
       // if it's an array type, we have to be careful
       String componentType;
  @@ -68,22 +72,22 @@
         // might be available
         int dims = arrayFD.indexOf("L");
         if (dims != -1 && dims<arrayFD.length()-2) {
  -	componentType = arrayFD.substring(dims+1,arrayFD.length()-1);
  -	return new ArrayJClass(loader.loadClass(componentType),dims);
  +        componentType = arrayFD.substring(dims+1,arrayFD.length()-1);
  +        return new ArrayJClass(loader.loadClass(componentType),dims);
         } else {
  -	// name is effed
  -	throw new IllegalArgumentException("array type field descriptor '"+
  -					   arrayFD+"' is malformed");
  +        // name is effed
  +        throw new IllegalArgumentException("array type field descriptor '"+
  +                                           arrayFD+"' is malformed");
         }
       } else {
         int dims = arrayFD.lastIndexOf("[")+1;
         JClass primType = PrimitiveJClass.getPrimitiveClassForName
  -	(arrayFD.substring(dims,dims+1));
  +              (arrayFD.substring(dims,dims+1));
         if (primType == null) {
  -	// if it didn't end with ';', it has to be a valid primitive
  -	// type name or it's effed
  -	throw new IllegalArgumentException("array type field descriptor '"+
  -					   arrayFD+"' is malformed");
  +        // if it didn't end with ';', it has to be a valid primitive
  +        // type name or it's effed
  +        throw new IllegalArgumentException("array type field descriptor '"+
  +                                           arrayFD+"' is malformed");
         }
         return new ArrayJClass(primType,dims);
       }
  @@ -106,7 +110,7 @@
       mComponentType = componentType;
       mDimensions = dimensions; 
     }
  -  
  +
     // ========================================================================
     // JElement implementation
   
  @@ -118,9 +122,9 @@
       String out = getQualifiedName();
       int lastDot = out.lastIndexOf('.');
       return (lastDot == -1) ? out : out.substring(lastDot+1);
  -  }    
  +  }
   
  -  public String getQualifiedName() { 
  +  public String getQualifiedName() {
       StringWriter out = new StringWriter();
       out.write(mComponentType.getQualifiedName());
       for(int i=0; i<mDimensions; i++) out.write("[]");
  @@ -144,7 +148,7 @@
   
     public int getModifiers() { return mComponentType.getModifiers(); }
   
  -  public boolean isPackagePrivate() { 
  +  public boolean isPackagePrivate() {
       return mComponentType.isPackagePrivate(); 
     }
   
  @@ -155,7 +159,7 @@
     public boolean isPrivate() { return mComponentType.isPrivate(); }
   
     public JSourcePosition getSourcePosition() { return null; }
  -  
  +
     public JClass getContainingClass() { return null; }
   
     // ========================================================================
  @@ -174,13 +178,13 @@
     public JClass getArrayComponentType() { return mComponentType; }
   
     public int getArrayDimensions() { return mDimensions; }
  -  
  +
     public JClass getSuperclass() { return ObjectJClass.getInstance(); }
   
     public boolean isAssignableFrom(JClass c) {
       return c.isArray() &&
  -      (c.getArrayDimensions() == mDimensions) &&
  -      (mComponentType.isAssignableFrom(c.getArrayComponentType()));
  +            (c.getArrayDimensions() == mDimensions) &&
  +            (mComponentType.isAssignableFrom(c.getArrayComponentType()));
     }
   
     public String getFieldDescriptor() {
  
  
  
  1.3       +1 -1      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJClassLoader.java
  
  Index: BaseJClassLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJClassLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseJClassLoader.java	2 Mar 2004 04:26:18 -0000	1.2
  +++ BaseJClassLoader.java	3 Mar 2004 00:01:42 -0000	1.3
  @@ -59,7 +59,7 @@
       JClass out = (JClass)mFd2Class.get(fd);
       if (out != null) return out;
       if (fd.startsWith("[")) {
  -      return ArrayJClass.createClassFor(fd,this);
  +      return ArrayJClass.createClassForFD(fd,this);
       } else {
         if (fd.equals("java.lang.Object")) return mParentLoader.loadClass(fd);
       }
  
  
  
  1.2       +2 -3      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JClassLoaderImpl.java
  
  Index: JClassLoaderImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/JClassLoaderImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JClassLoaderImpl.java	2 Mar 2004 04:26:18 -0000	1.1
  +++ JClassLoaderImpl.java	3 Mar 2004 00:01:42 -0000	1.2
  @@ -67,7 +67,7 @@
       JClass out = (JClass)mFd2ClassCache.get(fd);
       if (out != null) return out;
       if (fd.startsWith("[")) {
  -      return ArrayJClass.createClassFor(fd,this);
  +      return ArrayJClass.createClassForFD(fd,this);
       } else {
         if (fd.equals("java.lang.Object")) return ObjectJClass.getInstance();
         if (fd.equals("void")) return VoidJClass.getInstance();
  @@ -77,7 +77,6 @@
       String pkg;
       String name;
       if (dot == -1) {
  -      //System.out.println("==== "+fd);
         pkg = "";
         name = fd;
       } else {
  @@ -89,7 +88,7 @@
         out = ROOT.loadClass(fd);
       }
       if (out == null) {
  -      out = new EClassImpl(pkg,name,this);
  +      out = new EClassImpl(pkg,name,this,null);
         ((EClassImpl)out).setIsUnresolved(true);
         if (mVerbose) System.out.println("[JClassLoaderImpl] unresolve class '"+
                                          pkg+" "+name+"'!!");
  
  
  
  1.9       +1 -1      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/javadoc/JDClassLoader.java
  
  Index: JDClassLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/javadoc/JDClassLoader.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JDClassLoader.java	25 Feb 2004 18:56:49 -0000	1.8
  +++ JDClassLoader.java	3 Mar 2004 00:01:42 -0000	1.9
  @@ -72,7 +72,7 @@
     {
       fd = fd.trim();//REVIEW is this paranoid?
       if (fd.startsWith("[")) {
  -      return ArrayJClass.createClassFor(fd,this);
  +      return ArrayJClass.createClassForFD(fd,this);
       } else {
         if (fd.equals("java.lang.Object")) return mParentLoader.loadClass(fd);
         JClass out = (JClass)mFd2Class.get(fd);
  
  
  
  1.3       +1 -1      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/parser/ParserClassBuilder.java
  
  Index: ParserClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/parser/ParserClassBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParserClassBuilder.java	2 Mar 2004 06:32:13 -0000	1.2
  +++ ParserClassBuilder.java	3 Mar 2004 00:01:42 -0000	1.3
  @@ -41,7 +41,7 @@
     // ========================================================================
     // Constants
   
  -  private static final boolean VERBOSE = true;
  +  private static final boolean VERBOSE = false;
   
     // ========================================================================
     // Variables
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/parser/ParamStruct.java
  
  Index: ParamStruct.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.xmlbeans.impl.jam.internal.parser;
  
  import org.apache.xmlbeans.impl.jam.editable.EInvokable;
  import org.apache.xmlbeans.impl.jam.editable.EParameter;
  
  /**
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  /*package*/ class ParamStruct {
  
    // ========================================================================
    // Variables
  
    private String mName;
    private String mType;
  
    // ========================================================================
    // Constructors
  
    public ParamStruct(String type, String name) {
      init(type,name);
    }
  
    // ========================================================================
    // Public methods
  
    public void init(String type, String name) {
      mType = type;
      mName = name;
    }
  
    public EParameter createParameter(EInvokable e) {
      if (e == null) throw new IllegalArgumentException("null invokable");
      EParameter param = e.addNewParameter();
      param.setSimpleName(mName);
      param.setUnqualifiedType(mType);
      return param;
    }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/parser/ParamStructPool.java
  
  Index: ParamStructPool.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.xmlbeans.impl.jam.internal.parser;
  
  import org.apache.xmlbeans.impl.jam.editable.EInvokable;
  import org.apache.xmlbeans.impl.jam.editable.EParameter;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * <p>Utility class which the parser uses to store a list of method
   * or constructor parameters during lookahead.  The structures
   * get reused for efficiency.</p>
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public class ParamStructPool {
  
    // ========================================================================
    // Constants
  
    private static final boolean VERBOSE = true;
  
    // ========================================================================
    // Variables
  
    private List mList = new ArrayList();
    private int mLength = 0;
  
    // ========================================================================
    // Public methods
  
    public void setParametersOn(EInvokable e) {
      for(int i=0; i<mLength; i++) {
        ParamStruct struct = (ParamStruct)mList.get(i);
        struct.createParameter(e);
      }
    }
  
    public void add(String type, String name) {
      mLength++;
      if (mLength >= mList.size()) {
        mList.add(new ParamStruct(type,name));
      } else {
        ((ParamStruct)mList.get(mLength)).init(type,name);
      }
    }
  
    public void clear() {
      mLength = 0;
    }
  
  }
  
  
  
  1.2       +6 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/NewJServiceFactory.java
  
  Index: NewJServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/NewJServiceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NewJServiceFactory.java	2 Mar 2004 06:32:13 -0000	1.1
  +++ NewJServiceFactory.java	3 Mar 2004 00:01:42 -0000	1.2
  @@ -35,8 +35,12 @@
                                               JClassLoader parent)
             throws IOException
     {
  -    ParserClassBuilder pcb = new ParserClassBuilder(params);
  -    return new JClassLoaderImpl(pcb,null);
  +    EClassBuilder[] builders = new EClassBuilder[2];
  +    builders[0] = new ParserClassBuilder(params);
  +    // FIXME this is a temporary hack - we shouldnt have to do this
  +    builders[1] = ReflectionClassBuilder.getSystemClassBuilder();
  +    CompositeClassBuilder ccb = new CompositeClassBuilder(builders);
  +    return new JClassLoaderImpl(ccb,null);
     }
   
   }
  
  
  
  1.2       +5 -1      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/ReflectionClassBuilder.java
  
  Index: ReflectionClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/provider/ReflectionClassBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ReflectionClassBuilder.java	2 Mar 2004 04:26:18 -0000	1.1
  +++ ReflectionClassBuilder.java	3 Mar 2004 00:01:42 -0000	1.2
  @@ -48,6 +48,10 @@
       return new JClassLoaderImpl(new ReflectionClassBuilder(cl),null);
     }
   
  +  public static EClassBuilder getSystemClassBuilder() {
  +    return new ReflectionClassBuilder(ClassLoader.getSystemClassLoader());
  +  }
  +
     // ========================================================================
     // Constructors
   
  @@ -64,7 +68,7 @@
                         JClassLoader loader) {
       try {
         Class rclass = mLoader.loadClass(packageName+"."+className);
  -      EClass out = new EClassImpl(packageName, className, loader);
  +      EClass out = new EClassImpl(packageName, className, loader, null);
         populate(out,rclass);
         return out;
       } catch(ClassNotFoundException cnfe) {
  
  
  
  1.8       +2 -2      xml-xmlbeans/v2/test/src/jamtest/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/build.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- build.xml	2 Mar 2004 22:03:04 -0000	1.7
  +++ build.xml	3 Mar 2004 00:01:43 -0000	1.8
  @@ -57,9 +57,9 @@
         </classpath>
         <formatter type='plain' usefile='false'/>
   
  -      <!--
  +
         <test name='org.apache.xmlbeans.test.jam.ParserJamTest'/>
  -      -->
  +
         <test name='org.apache.xmlbeans.test.jam.SourcesJamTest'/>
         <test name='org.apache.xmlbeans.test.jam.ClassesJamTest'/>
   
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/GoldenInvokable.java
  
  Index: GoldenInvokable.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/GoldenInvokable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GoldenInvokable.java	2 Mar 2004 22:03:04 -0000	1.1
  +++ GoldenInvokable.java	3 Mar 2004 00:01:43 -0000	1.2
  @@ -132,7 +132,7 @@
   
     public void compare(JMethod method, boolean compareParamNames, Assert a) {
       compare((JInvokable)method,compareParamNames,a);
  -    a.assertTrue("return types are different ["+
  +    a.assertTrue("return types are different on "+method.getSimpleName()+"["+
                    method.getReturnType().getQualifiedName()+","+
                    mReturnType+"]",
                    method.getReturnType().getQualifiedName().equals(mReturnType));
  
  
  
  1.8       +3 -2      xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
  
  Index: JamTestBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JamTestBase.java	2 Mar 2004 22:03:04 -0000	1.7
  +++ JamTestBase.java	3 Mar 2004 00:01:43 -0000	1.8
  @@ -329,8 +329,9 @@
   
     private void verifyAnnotation(JElement j, String ann, String val) {
       JAnnotation a = j.getAnnotation(ann);
  -    assertTrue(j.getParent().getQualifiedName()+" '"+j.getQualifiedName()+"' is missing
expected annotation '"+ann+"'",
  -                a != null);
  +    assertTrue(/*j.getParent().getQualifiedName()+" '"+*/
  +            j.getQualifiedName()+"' is missing expected annotation '"+ann+"'",
  +            a != null);
       assertTrue(j.getQualifiedName()+"  annotation '"+ann+"' does not equal "+
                  val,val.equals(a.getStringValue().trim()));
     }
  
  
  
  1.4       +1 -1      xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/ParserJamTest.java
  
  Index: ParserJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/ParserJamTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ParserJamTest.java	2 Mar 2004 08:28:19 -0000	1.3
  +++ ParserJamTest.java	3 Mar 2004 00:01:43 -0000	1.4
  @@ -45,7 +45,7 @@
     }
   
     protected boolean isAnnotationsAvailable() {
  -    return true;
  +    return false;//FIXME!!
     }
   
     protected boolean isParameterNamesKnown() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message