You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by pc...@apache.org on 2004/03/16 06:34:50 UTC

cvs commit: xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam ClassesJamTest.java JamTestBase.java SourcesJamTest.java

pcal        2004/03/15 21:34:50

  Modified:    v2/jam   build.xml
               v2/jam/src/org/apache/xmlbeans/impl/jam
                        JamServiceFactory.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/annotation
                        AnnotationProxy.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements
                        AnnotatedElementImpl.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc
                        JavadocClassBuilder.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/provider
                        JamServiceFactoryImpl.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/xml
                        JamXmlWriter.java
               v2/jam/test build.xml
               v2/jam/test/tests/org/apache/xmlbeans/test/jam
                        ClassesJamTest.java JamTestBase.java
                        SourcesJamTest.java
  Added:       v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15
                        Javadoc15AnnotationExtractor.java
                        Reflect15AnnotationExtractor.java java15jam.jar
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc
                        JavadocAnnotationExtractor.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect
                        ReflectAnnotationExtractor.java
                        ReflectClassBuilder.java
               v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/jsr175
                        AnnotatedClass.java RFEAnnotation.java
                        RFEAnnotationImpl.java
  Removed:     v2/jam/src/org/apache/xmlbeans/impl/jam/internal
                        ReflectingClassBuilder.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/xml
                        TunnelledXMLException.java
               v2/jam/test/dummy15classes/org/apache/xmlbeans/test/jam/dummyclasses/jsr175
                        AnnotatedClass.java RFEAnnotation.java
                        RFEAnnotationImpl.java
  Log:
  jam: refactor 15-specific stuff
  
  Revision  Changes    Path
  1.11      +23 -1     xml-xmlbeans/v2/jam/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/build.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- build.xml	15 Mar 2004 23:47:36 -0000	1.10
  +++ build.xml	16 Mar 2004 05:34:49 -0000	1.11
  @@ -17,6 +17,10 @@
     <property name='classes_dir' value='${build_dir}/classes'/>
     <property name='antlr_jar'   value='external/lib/antlr.jar'/>
   
  +  <property name="java15_src"   value='org/apache/xmlbeans/impl/jam/internal/java15'/>
  +  <property name="java15_jar"   value='${src_dir}/${java15_src}/java15jam.jar'/>
  +  <property name='java15_builddir'  value='${build_dir}/java15'/>
  +
     <!--FIXME need to do get the jar ourselves -->
     <property name='staxapi_jar'   value='../build/lib/jsr173_api.jar'/>
   
  @@ -53,7 +57,7 @@
       <mkdir dir='${classes_dir}'/>
   
       <javac srcdir='${src_dir}' destdir='${classes_dir}'
  -           source='1.4' debug='on'>
  +           source='1.4' debug='on' excludes='${java15_src}/**/*.java'>
         <src path='${src_dir}'/>
         <src path='${gen_dir}'/>
         <classpath>
  @@ -64,6 +68,8 @@
         </classpath>
       </javac>
   
  +    <unjar src='${java15_jar}' dest='${classes_dir}'/>
  +
     </target>
   
     <target name='test'>
  @@ -110,6 +116,20 @@
     </target>
   
   
  +  <!-- recompiles java15_jar.  THIS ONLY WILL RUN WITH JDK1.5!! -->
  +  <target name='java15jar'>
  +    <mkdir dir='${java15_builddir}'/>
  +    <javac srcdir='${src_dir}' destdir='${java15_builddir}'
  +           source='1.5' target='1.5' debug='on' includes='${java15_src}/**/*.java'>
  +      <classpath>
  +        <pathelement path='${classes_dir}'/>
  +        <pathelement path='${java.class.path}'/>
  +      </classpath>
  +    </javac>
  +    <jar jarfile='${java15_jar}' basedir='${java15_builddir}' update='false'/>
  +  </target>
  +
  +
     <target name='repackage' depends='clean,repackage_check,repackage_do'/>
   
     <target name='repackage_check' unless='newpackage'>
  @@ -147,5 +167,7 @@
         <property name='src_dir' value='${repackaged_src}'/>
       </ant>
     </target>
  +  
  +  
   
   </project>
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JamServiceFactory.java
  
  Index: JamServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JamServiceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JamServiceFactory.java	9 Mar 2004 10:38:51 -0000	1.1
  +++ JamServiceFactory.java	16 Mar 2004 05:34:49 -0000	1.2
  @@ -16,7 +16,7 @@
   package org.apache.xmlbeans.impl.jam;
   
   import org.apache.xmlbeans.impl.jam.internal.JamPrinter;
  -import org.apache.xmlbeans.impl.jam.internal.ReflectingClassBuilder;
  +import org.apache.xmlbeans.impl.jam.internal.reflect.ReflectClassBuilder;
   import org.apache.xmlbeans.impl.jam.provider.JamServiceFactoryImpl;
   
   import java.io.File;
  
  
  
  1.3       +13 -3     xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/AnnotationProxy.java
  
  Index: AnnotationProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/AnnotationProxy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AnnotationProxy.java	10 Mar 2004 11:42:07 -0000	1.2
  +++ AnnotationProxy.java	16 Mar 2004 05:34:49 -0000	1.3
  @@ -130,13 +130,23 @@
         if (Modifier.isStatic(mods)) continue;
         if (!Modifier.isPublic(mods)) continue;
         if (methods[i].getParameterTypes().length > 0) continue;
  +      {
  +        // try to limit it to real annotation methods.  
  +        // FIXME seems like this could be better
  +        Class c = methods[i].getDeclaringClass();
  +        String name = c.getName();
  +        if (name.equals("java.lang.Object") ||
  +          name.equals("java.lang.annotation.Annotation")) {
  +          continue;
  +        }
  +      }
         try {
           setValue(methods[i].getName(),
  -                       methods[i].invoke(jsr175annotationObject,null));
  +                 methods[i].invoke(jsr175annotationObject,null));
         } catch (IllegalAccessException e) {
  -        getLogger().warning(e);
  +        //getLogger().warning(e);
         } catch (InvocationTargetException e) {
  -        getLogger().warning(e);
  +        //getLogger().warning(e);
         }
       }
     }
  
  
  
  1.6       +2 -1      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java
  
  Index: AnnotatedElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AnnotatedElementImpl.java	11 Mar 2004 23:01:41 -0000	1.5
  +++ AnnotatedElementImpl.java	16 Mar 2004 05:34:49 -0000	1.6
  @@ -134,7 +134,8 @@
       String typename = getAnnotationTypeFor(jsr175annotationInstance);
       MAnnotation ann = getMutableAnnotation(typename);
       if (ann != null) {
  -      //REVIEW this is an extremely weird case where they add another instance
  +      ann.getMutableProxy().initFromAnnotationInstance(jsr175annotationInstance);
  +      //REVIEW this is a weird case where they add another instance
         // of the same annotation type.  We'll just go with it for now,
         // but we might want to throw an exception here, not sure.
       } else {
  
  
  
  1.1                  xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15/Javadoc15AnnotationExtractor.java
  
  Index: Javadoc15AnnotationExtractor.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.java15;
  
  import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
  import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
  import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
  import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocAnnotationExtractor;
  import com.sun.javadoc.ProgramElementDoc;
  import com.sun.javadoc.AnnotationDesc;
  import com.sun.javadoc.Parameter;
  
  
  /**
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class Javadoc15AnnotationExtractor implements JavadocAnnotationExtractor {
  
    public void extractAnnotations(MAnnotatedElement dest,
                                   ProgramElementDoc src) {
      extractAnnotations(dest,src.annotations());
    }
  
    public void extractAnnotations(MAnnotatedElement dest, Parameter src) {
      //FIXME javadoc doesn't yet support parameter annotations
      //pcal 3/15/04
      //
      //extractAnnotations(dest,src.annotations());
    }
  
    // ========================================================================
    // Private methods
  
  
    private void extractAnnotations(MAnnotatedElement dest,
                                    AnnotationDesc[] anns)
    {
      if (anns == null) return;
      for(int i=0; i<anns.length; i++) {
        MAnnotation destAnn = dest.addAnnotationForType
          (anns[i].annotationType().asClassDoc().qualifiedName());
        AnnotationProxy destProxy = destAnn.getMutableProxy();
        AnnotationDesc.MemberValuePair[] mvps = anns[i].memberValues();
        for(int j=0; j<mvps.length; j++) {
          destProxy.setValue(mvps[j].member().name(),
                             mvps[j].value());
          //FIXME deal with nested data
        }
      }
    }
  }
  
  
  1.1                  xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15/Reflect15AnnotationExtractor.java
  
  Index: Reflect15AnnotationExtractor.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.java15;
  
  import org.apache.xmlbeans.impl.jam.internal.reflect.ReflectAnnotationExtractor;
  import org.apache.xmlbeans.impl.jam.mutable.MMember;
  import org.apache.xmlbeans.impl.jam.mutable.MConstructor;
  import org.apache.xmlbeans.impl.jam.mutable.MField;
  import org.apache.xmlbeans.impl.jam.mutable.MClass;
  import org.apache.xmlbeans.impl.jam.mutable.MParameter;
  
  import java.lang.reflect.Method;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Field;
  import java.lang.annotation.Annotation;
  
  /**
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class Reflect15AnnotationExtractor implements ReflectAnnotationExtractor {
  
    public void extractAnnotations(MMember dest, Method src) {
      Annotation[] anns = src.getDeclaredAnnotations();
      if (anns == null) return;
      for(int i=0; i<anns.length; i++) dest.addAnnotationForInstance(anns[i]);
    }
  
    public void extractAnnotations(MConstructor dest, Constructor src) {
      Annotation[] anns = src.getDeclaredAnnotations();
      if (anns == null) return;
      for(int i=0; i<anns.length; i++) dest.addAnnotationForInstance(anns[i]);
    }
  
    public void extractAnnotations(MField dest, Field src) {
      Annotation[] anns = src.getDeclaredAnnotations();
      if (anns == null) return;
      for(int i=0; i<anns.length; i++) dest.addAnnotationForInstance(anns[i]);
    }
  
    public void extractAnnotations(MClass dest, Class src) {
      Annotation[] anns = src.getDeclaredAnnotations();
      if (anns == null) return;
      for(int i=0; i<anns.length; i++) dest.addAnnotationForInstance(anns[i]);
    }
  
    public void extractAnnotations(MParameter dest, Method src, int paramNum) {
      Annotation[][] anns = src.getParameterAnnotations();
      if (anns == null) return;
      for(int i=0; i<anns[paramNum].length; i++) {
        dest.addAnnotationForInstance(anns[paramNum][i]);
      }
    }
  
    public void extractAnnotations(MParameter dest, Constructor src,
                                   int paramNum) {
      Annotation[][] anns;
      try {
        anns = src.getParameterAnnotations();
      } catch(NullPointerException wtf) {
        //FIXME sun code throws an NPE here
  //      System.err.println("[Reflect15AnnotationExtractor] Ignoring apprent bug in reflection");
        //wtf.printStackTrace();
        return;
      }
      if (anns == null) return;
      for(int i=0; i<anns[paramNum].length; i++) {
        dest.addAnnotationForInstance(anns[paramNum][i]);
      }
    }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15/java15jam.jar
  
  	<<Binary file>>
  
  
  1.7       +36 -117   xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocClassBuilder.java
  
  Index: JavadocClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocClassBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JavadocClassBuilder.java	16 Mar 2004 01:33:24 -0000	1.6
  +++ JavadocClassBuilder.java	16 Mar 2004 05:34:50 -0000	1.7
  @@ -15,18 +15,15 @@
   package org.apache.xmlbeans.impl.jam.internal.javadoc;
   
   import com.sun.javadoc.*;
  -import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
   import org.apache.xmlbeans.impl.jam.mutable.*;
   import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
   import org.apache.xmlbeans.impl.jam.internal.elements.PrimitiveClassImpl;
   import org.apache.xmlbeans.impl.jam.internal.JamServiceContextImpl;
   import org.apache.xmlbeans.impl.jam.provider.JamClassBuilder;
   import org.apache.xmlbeans.impl.jam.provider.JamServiceContext;
  -import org.apache.xmlbeans.impl.jam.JClass;
   
   import java.io.*;
  -import java.lang.reflect.Method;
  -import java.lang.reflect.InvocationTargetException;
  +import java.util.StringTokenizer;
   
   /**
    * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
  @@ -36,21 +33,37 @@
     // ========================================================================
     // Constants
   
  +  public static final String ARGS_PROPERTY = "javadoc.args";
  +
     private static boolean VERBOSE = false;
  +  private static final String JAVA15_EXTRACTOR = 
  +    "org.apache.xmlbeans.impl.jam.internal.java15.Javadoc15AnnotationExtractor";
   
     // ========================================================================
     // Variables
   
     private RootDoc mRootDoc = null;
     private JamServiceContext mServiceContext;
  -  private boolean mIs15 = false;
  +  private JavadocAnnotationExtractor mExtractor = null;
   
     // ========================================================================
     // Constructors
   
     public JavadocClassBuilder(JamServiceContext ctx) {
  +    if (ctx == null) throw new IllegalArgumentException("null context");
       mServiceContext = ctx;
  -    init175getters();
  +    try {
  +      mExtractor = (JavadocAnnotationExtractor)
  +        Class.forName(JAVA15_EXTRACTOR).newInstance();
  +    } catch (ClassNotFoundException e) {
  +      ctx.error(e);
  +    } catch (IllegalAccessException e) {
  +      //if this fails, we'll assume it's because we're not under 1.5
  +      ctx.debug(e);
  +    } catch (InstantiationException e) {
  +      //if this fails, we'll assume it's because we're not under 1.5
  +      ctx.debug(e);
  +    }
     }
   
     // ========================================================================
  @@ -83,7 +96,7 @@
                            out,
                            sourcePath,
                            classPath,
  -                         null);//FIXME get javadoc args from param props
  +                         getJavadocArgs(mServiceContext));
         if (mRootDoc == null) {
           ctx.debug("Javadoc returned a null root");//FIXME error
         }
  @@ -94,8 +107,6 @@
       }
     }
   
  -
  -
     public MClass build(String packageName, String className) {
       if (VERBOSE) {
         System.out.println("[JavadocClassBuilder] building '"+
  @@ -175,9 +186,22 @@
       dest.setArtifact(src);
       dest.setSimpleName(src.name());
       dest.setType(getFdFor(src.type()));
  -    if (mIs15) addAnnotations(dest, callGetAnnotations(src));
  +    if (mExtractor != null) mExtractor.extractAnnotations(dest,src);
     }
   
  +
  +  private String[] getJavadocArgs(JamServiceContext ctx) {
  +    String prop = ctx.getProperty(ARGS_PROPERTY);
  +    if (prop == null) return null;
  +
  +    StringTokenizer t = new StringTokenizer(prop);
  +    String[] out = new String[t.countTokens()];
  +    int i = 0;
  +    while(t.hasMoreTokens()) out[i++] = t.nextToken();
  +    return out;
  +  }
  +
  +
     /**
      * Returns a classfile-style field descriptor for the given type.
      * This has to be called to get a name for a javadoc type that can
  @@ -216,115 +240,10 @@
     }
   
   
  +
     private void addAnnotations(MAnnotatedElement dest, ProgramElementDoc src) {
       String comments = src.getRawCommentText();
       if (comments != null) dest.createComment().setText(comments);
  -    if (mIs15) addAnnotations(dest,callGetAnnotations(src));
  -  }
  -
  -  private void addAnnotations(MAnnotatedElement dest, Object[] descs) {
  -    if (descs == null) return;
  -    if (!mIs15) return;
  -    for(int i=0; i<descs.length; i++) {
  -      MAnnotation ann =
  -        dest.addAnnotationForType(callGetAnnotationType(descs[i]).qualifiedTypeName());
  -      ann.setArtifact(descs[i]);
  -      AnnotationProxy proxy = ann.getMutableProxy();
  -      Object[] mvps = callGetMemberValues(descs[i]);
  -      for(int j=0; j<mvps.length; j++) {
  -        String name = callGetMvpName(mvps[i]);
  -        Object value = callGetMvpValue(mvps[i]);
  -        if (name != null && value != null) proxy.setValue(name,value);
  -      }
  -    }
  -  }
  -
  -
  -  // ========================================================================
  -  // Goofy reflection stuff to keep us 1.4-safe
  -
  -  private Method mAnnotationGetter;
  -  private Method mParameterAnnotationGetter;
  -  private Method mAnnotationTypeGetter;
  -  private Method mMemberValuesGetter;
  -  private Method mMvpName;
  -  private Method mMvpValue;
  -
  -  private Object[] callGetAnnotations(ProgramElementDoc pd) {
  -    if (mAnnotationGetter == null) return null;
  -    return (Object[])invoke(mAnnotationGetter,pd);
  -  }
  -
  -  private Object[] callGetAnnotations(Parameter p) {
  -    if (mParameterAnnotationGetter == null) return null;
  -    return (Object[])invoke(mParameterAnnotationGetter,p);
  -  }
  -
  -  private ClassDoc callGetAnnotationType(Object desc) {
  -    if (mAnnotationTypeGetter == null) return null;
  -    return (ClassDoc)invoke(mAnnotationTypeGetter, desc);
  -  }
  -
  -  private Object[] callGetMemberValues(Object desc) {
  -    if (mMemberValuesGetter == null) return null;
  -    return (Object[])invoke(mMemberValuesGetter, desc);
  -  }
  -
  -  private String callGetMvpName(Object mvp) {
  -    if (mMvpName == null) return null;
  -    return (String)invoke(mMvpName, mvp);
  -  }
  -
  -  private Object callGetMvpValue(Object mvp) {
  -    if (mMvpValue == null) return null;
  -    return invoke(mMvpValue, mvp);
  -  }
  -
  -  private void init175getters() {
  -    mAnnotationGetter = getGetter(ProgramElementDoc.class,"annotations");
  -    mParameterAnnotationGetter = getGetter(Parameter.class,"annotations");
  -    try {
  -      Class annotationDesc = Class.forName("com.sun.javadoc.AnnotationDesc");
  -      mAnnotationTypeGetter = getGetter(annotationDesc, "annotationType");
  -      mMemberValuesGetter = getGetter(annotationDesc, "memberValues");
  -    } catch (ClassNotFoundException e) {
  -      mServiceContext.debug(e);
  -    }
  -    try {
  -      Class annotationDesc = Class.forName("com.sun.javadoc.AnnotationDesc.");
  -      mAnnotationTypeGetter = getGetter(annotationDesc, "annotationType");
  -      mMemberValuesGetter = getGetter(annotationDesc, "memberValues");
  -    } catch (ClassNotFoundException e) {
  -      mServiceContext.debug(e);
  -    }
  -    try {
  -      Class mvp = Class.forName("com.sun.javadoc.AnnotationDesc.MemberValuePair");
  -      mMvpName = getGetter(mvp, "name");
  -      mMvpValue = getGetter(mvp, "value");
  -    } catch (ClassNotFoundException e) {
  -      mServiceContext.debug(e);
  -    }
  -    mIs15 = true;
  -  }
  -
  -  private Method getGetter(Class c, String name) {
  -    try {
  -      return c.getMethod(name, null);
  -    } catch (NoSuchMethodException e) {
  -      mServiceContext.debug(e);
  -    }
  -    return null;
  +    if (mExtractor != null) mExtractor.extractAnnotations(dest,src);
     }
  -
  -  private Object invoke(Method m, Object target) {
  -    try {
  -      return m.invoke(target,null);
  -    } catch (IllegalAccessException e) {
  -      mServiceContext.debug(e);
  -    } catch (InvocationTargetException e) {
  -      mServiceContext.debug(e);
  -    }
  -    return null;
  -  }
  -
   }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocAnnotationExtractor.java
  
  Index: JavadocAnnotationExtractor.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.javadoc;
  
  import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
  import com.sun.javadoc.ProgramElementDoc;
  import com.sun.javadoc.Parameter;
  
  /**
   * Provides an interface to 1.5-specific functionality.  The impl of
   * this class is loaded by-name at runtime.
   *
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public interface JavadocAnnotationExtractor {
  
    public void extractAnnotations(MAnnotatedElement dest,
                                   ProgramElementDoc src);
  
    public void extractAnnotations(MAnnotatedElement dest,
                                   Parameter src);
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectAnnotationExtractor.java
  
  Index: ReflectAnnotationExtractor.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.reflect;
  
  import org.apache.xmlbeans.impl.jam.mutable.MMember;
  import org.apache.xmlbeans.impl.jam.mutable.MConstructor;
  import org.apache.xmlbeans.impl.jam.mutable.MClass;
  import org.apache.xmlbeans.impl.jam.mutable.MParameter;
  import org.apache.xmlbeans.impl.jam.mutable.MField;
  
  import java.lang.reflect.Method;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Field;
  
  /**
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public interface ReflectAnnotationExtractor {
    
    public void extractAnnotations(MMember dest, Method src);
  
    public void extractAnnotations(MConstructor dest, Constructor src);
  
    public void extractAnnotations(MField dest, Field src);
  
    public void extractAnnotations(MClass dest, Class src);
  
    public void extractAnnotations(MParameter dest, Method src, int paramNum);
  
    public void extractAnnotations(MParameter dest, Constructor src, int paramNum);  
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectClassBuilder.java
  
  Index: ReflectClassBuilder.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.reflect;
  
  import org.apache.xmlbeans.impl.jam.mutable.*;
  import org.apache.xmlbeans.impl.jam.provider.JamClassBuilder;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Field;
  import java.lang.reflect.Method;
  
  /**
   *
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class ReflectClassBuilder extends JamClassBuilder {
  
    // ========================================================================
    // Constants
  
    private static final String JAVA15_EXTRACTOR =
      "org.apache.xmlbeans.impl.jam.internal.java15.Reflect15AnnotationExtractor";
  
    // ========================================================================
    // Public static utilities
  
    public static JamClassBuilder getSystemClassBuilder() {
      return new ReflectClassBuilder(ClassLoader.getSystemClassLoader());
    }
  
    // ========================================================================
    // Variables
  
    private ClassLoader mLoader;
    private ReflectAnnotationExtractor mExtractor = null;
  
    // ========================================================================
    // Constructors
  
    public ReflectClassBuilder(ClassLoader rcl) {
      if (rcl == null) throw new IllegalArgumentException("null rcl");
      mLoader = rcl;
      try {
        mExtractor = (ReflectAnnotationExtractor)
          Class.forName(JAVA15_EXTRACTOR).newInstance();
      } catch (ClassNotFoundException e) {
        //      ctx.error(e);
      } catch (IllegalAccessException e) {
        //if this fails, we'll assume it's because we're not under 1.5
        //    ctx.debug(e);
      } catch (InstantiationException e) {
        //if this fails, we'll assume it's because we're not under 1.5
        //  ctx.debug(e);
      }
    }
  
    // ========================================================================
    // JamClassBuilder implementation
  
    public MClass build(String packageName, String className)
    {
      Class rclass;
      try {
        rclass = mLoader.loadClass(packageName+"."+className);
      } catch(ClassNotFoundException cnfe) {
  //      getLogger().debug(cnfe);
        return null;
      }
      MClass out = createClassToBuild(packageName, className, null);
      populate(out,rclass);
      return out;
    }
  
    // ========================================================================
    // Private methods
  
    private void populate(MClass dest, Class src) {
      dest.setModifiers(src.getModifiers());
      dest.setIsInterface(src.isInterface());
      // set the superclass
      Class s = src.getSuperclass();
      if (s != null) dest.setSuperclass(s.getName());
      // set the interfaces
      Class[] ints = src.getInterfaces();
      for(int i=0; i<ints.length; i++) dest.addInterface(ints[i].getName());
      // add the fields
      Field[] fields = src.getFields();
      for(int i=0; i<fields.length; i++) populate(dest.addNewField(),fields[i]);
      // add the methods
      Method[] methods = src.getDeclaredMethods();
      for(int i=0; i<methods.length; i++) populate(dest.addNewMethod(),methods[i]);
      // add the constructors
      Constructor[] ctors = src.getDeclaredConstructors();
      for(int i=0; i<ctors.length; i++) populate(dest.addNewConstructor(),ctors[i]);
      // add the annotations
      if (mExtractor != null) mExtractor.extractAnnotations(dest,src);
    }
  
    private void populate(MField dest, Field src) {
      dest.setSimpleName(src.getName());
      dest.setType(src.getType().getName());
      dest.setModifiers(src.getModifiers());
      if (mExtractor != null) mExtractor.extractAnnotations(dest,src);
    }
  
    private void populate(MConstructor dest, Constructor src) {
      dest.setSimpleName(src.getName());
      dest.setModifiers(src.getModifiers());
      Class[] exceptions = src.getExceptionTypes();
      addThrows(dest,exceptions);
      Class[] paramTypes = src.getParameterTypes();
      for(int i=0; i<paramTypes.length; i++) {
        MParameter p = addParameter(dest, i, paramTypes[i]);
        if (mExtractor != null) mExtractor.extractAnnotations(p,src,i);
      }
      if (mExtractor != null) mExtractor.extractAnnotations(dest,src);
    }
  
    private void populate(MMethod dest, Method src) {
      dest.setSimpleName(src.getName());
      dest.setModifiers(src.getModifiers());
      dest.setReturnType(src.getReturnType().getName());
      Class[] exceptions = src.getExceptionTypes();
      addThrows(dest,exceptions);
      Class[] paramTypes = src.getParameterTypes();
      for(int i=0; i<paramTypes.length; i++) {
        MParameter p = addParameter(dest, i, paramTypes[i]);
        if (mExtractor != null) mExtractor.extractAnnotations(p,src,i);
      }
      if (mExtractor != null) mExtractor.extractAnnotations(dest,src);
    }
  
    private void addThrows(MInvokable dest, Class[] exceptionTypes) {
      for(int i=0; i<exceptionTypes.length; i++) {
        dest.addException(exceptionTypes[i].getName());
      }
    }
  
    private MParameter addParameter(MInvokable dest,
                                    int paramNum,
                                    Class paramType)
    {
      MParameter p = dest.addNewParameter();
      p.setSimpleName("param"+paramNum);
      p.setType(paramType.getName());
      return p;
    }
  
  
  
  
  //salvaged from RClassLoader, may be useful for parser
    /*
    private void validateClassName(String className)
            throws IllegalArgumentException
    {
      if (!Character.isJavaIdentifierStart(className.charAt(0))) {
        throw new IllegalArgumentException
                ("Invalid first character in class name: "+className);
      }
      for(int i=1; i<className.length(); i++) {
        char c = className.charAt(i);
        if (c == '.') {
          if (className.charAt(i-1) == '.') {
            throw new IllegalArgumentException
                    ("'..' not allowed in class name: "+className);
          }
          if (i == className.length()-1) {
            throw new IllegalArgumentException
                    ("'.' not allowed at end of class name: "+className);
          }
        } else {
          if (!Character.isJavaIdentifierPart(c)) {
            throw new IllegalArgumentException
                    ("Illegal character '"+c+"' in class name: "+className);
          }
        }
      }
    }
    */
  }
  
  
  
  1.3       +4 -3      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java
  
  Index: JamServiceFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JamServiceFactoryImpl.java	9 Mar 2004 11:47:10 -0000	1.2
  +++ JamServiceFactoryImpl.java	16 Mar 2004 05:34:50 -0000	1.3
  @@ -21,7 +21,8 @@
   import org.apache.xmlbeans.impl.jam.internal.JamClassLoaderImpl;
   import org.apache.xmlbeans.impl.jam.internal.JamServiceContextImpl;
   import org.apache.xmlbeans.impl.jam.internal.JamServiceImpl;
  -import org.apache.xmlbeans.impl.jam.internal.ReflectingClassBuilder;
  +import org.apache.xmlbeans.impl.jam.internal.reflect.ReflectClassBuilder;
  +import org.apache.xmlbeans.impl.jam.internal.reflect.ReflectClassBuilder;
   import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
   import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocClassBuilder;
   import org.apache.xmlbeans.impl.jam.internal.parser.ParserClassBuilder;
  @@ -125,7 +126,7 @@
       b = createClassfileBuilder(ctx);  // then custom classpath
       if (b != null) builders.add(b);
       if (ctx.isUseSystemClasspath()) { // then system classpath
  -      builders.add(ReflectingClassBuilder.getSystemClassBuilder());
  +      builders.add(ReflectClassBuilder.getSystemClassBuilder());
       }
       JamClassBuilder[] barray = new JamClassBuilder[builders.size()];
       builders.toArray(barray);
  @@ -170,7 +171,7 @@
       } else {
         URL[] urls = cp.toUrlPath();
         ClassLoader cl = new URLClassLoader(urls);
  -      return new ReflectingClassBuilder(cl);
  +      return new ReflectClassBuilder(cl);
       }
     }
   
  
  
  
  1.4       +204 -7    xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/xml/JamXmlWriter.java
  
  Index: JamXmlWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/xml/JamXmlWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JamXmlWriter.java	15 Mar 2004 22:49:52 -0000	1.3
  +++ JamXmlWriter.java	16 Mar 2004 05:34:50 -0000	1.4
  @@ -24,20 +24,47 @@
   import org.apache.xmlbeans.impl.jam.JComment;
   import org.apache.xmlbeans.impl.jam.JAnnotatedElement;
   import org.apache.xmlbeans.impl.jam.JInvokable;
  -import org.apache.xmlbeans.impl.jam.visitor.JVisitor;
  +import org.apache.xmlbeans.impl.jam.JSourcePosition;
  +import org.apache.xmlbeans.impl.jam.JAnnotationValue;
   
  +import javax.xml.stream.XMLStreamWriter;
  +import javax.xml.stream.XMLStreamException;
  +import javax.xml.stream.XMLOutputFactory;
   import java.io.Writer;
   
   /**
    * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
    */
  -public class JamXmlWriter extends JVisitor {
  -  /*
  +public class JamXmlWriter {
  +
     // ========================================================================
     // Constants
   
  -  private static final String PACKAGE_ELEMENT = "package";
  -  private static final String CLASS_ELEMENT = "class";  
  +  public static final String PACKAGE_ELEMENT = "package";
  +
  +  public static final String CLASS_ELEMENT = "class";
  +  public static final String NAME_ELEMENT = "name";
  +  public static final String ISINTERFACE_ELEMENT = "is-interface";
  +  public static final String INTERFACE_ELEMENT = "interface";
  +  public static final String SUPERCLASS_ELEMENT = "superclass";
  +  public static final String MODIFIERS_ELEMENT = "modifiers";
  +  public static final String PARAMETER_ELEMENT = "parameter";
  +  public static final String TYPE_ELEMENT = "parameter";
  +  public static final String CONSTRUCTOR_ELEMENT = "constructor";
  +  public static final String METHOD_ELEMENT = "method";
  +  public static final String FIELD_ELEMENT = "field";
  +  public static final String RETURNTYPE_ELEMENT = "return-type";
  +  public static final String COMMENT_ELEMENT = "comment";
  +
  +  public static final String SOURCEPOSITION_ELEMENT = "source-position";
  +  public static final String LINE_ELEMENT = "line";
  +  public static final String COLUMN_ELEMENT = "column";
  +  public static final String SOURCEURI_ELEMENT = "source-uri";
  +
  +  public static final String VALUE_ELEMENT = "value";
  +
  +  public static final String ANNOTATION_ELEMENT = "annotation";
  +  public static final String ANNOTATIONVALUE_ELEMENT = "annotation-value";
   
     // ========================================================================
     // Variables
  @@ -56,8 +83,178 @@
       if (out == null) throw new IllegalArgumentException("null out");
       mOut = out;
     }
  -  */
  -}
   
  +  // ========================================================================
  +  // Public methods
   
  +  public void write(JPackage pkg) throws XMLStreamException {
  +    mOut.writeStartElement(PACKAGE_ELEMENT);
  +    JClass[] c = pkg.getClasses();
  +    for(int i=0; i<c.length; i++) write(c[i]);
  +    writeAnnotatedElement(pkg);
  +    mOut.writeEndElement();
  +  }
  +
  +  public void write(JClass clazz) throws XMLStreamException {
  +    mOut.writeStartElement(CLASS_ELEMENT);
  +    writeValueElement(NAME_ELEMENT,clazz.getQualifiedName());
  +    writeValueElement(ISINTERFACE_ELEMENT,clazz.isInterface());
  +    JClass sc = clazz.getSuperclass();
  +    if (sc != null) writeValueElement(SUPERCLASS_ELEMENT,sc.getQualifiedName());
  +    writeClassList(INTERFACE_ELEMENT,clazz.getInterfaces());
  +    writeModifiers(clazz.getModifiers());
  +    {
  +      JField[] f = clazz.getDeclaredFields();
  +      for(int i=0; i<f.length; i++) write(f[i]);
  +    }{
  +      JConstructor[] c = clazz.getConstructors();
  +      for(int i=0; i<c.length; i++) write(c[i]);
  +    }{
  +      JMethod[] m = clazz.getDeclaredMethods();
  +      for(int i=0; i<m.length; i++) write(m[i]);
  +    }
  +    //FIXME inner classes?
  +    writeAnnotatedElement(clazz);
  +    mOut.writeEndElement();
  +  }
   
  +  public void write(JMethod method) throws XMLStreamException {
  +    mOut.writeStartElement(METHOD_ELEMENT);
  +    writeValueElement(NAME_ELEMENT,method.getSimpleName());
  +    writeValueElement(RETURNTYPE_ELEMENT,
  +                      method.getReturnType().getQualifiedName());
  +    writeInvokable(method);
  +    mOut.writeEndElement();
  +  }
  +
  +  public void write(JConstructor ctor) throws XMLStreamException {
  +    mOut.writeStartElement(CONSTRUCTOR_ELEMENT);
  +    writeInvokable(ctor);
  +    mOut.writeEndElement();
  +  }
  +
  +  public void write(JField field) throws XMLStreamException {
  +    mOut.writeStartElement(FIELD_ELEMENT);
  +    writeValueElement(NAME_ELEMENT,field.getSimpleName());
  +    writeModifiers(field.getModifiers());
  +    writeValueElement(TYPE_ELEMENT,field.getType().getQualifiedName());
  +    writeAnnotatedElement(field);
  +    mOut.writeEndElement();
  +  }
  +
  +  // ========================================================================
  +  // Private methods
  +
  +  private void writeInvokable(JInvokable ji) throws XMLStreamException {
  +    writeModifiers(ji.getModifiers());
  +    JParameter[] params = ji.getParameters();
  +    for(int i=0; i<params.length; i++) {
  +      mOut.writeStartElement(PARAMETER_ELEMENT);
  +      writeValueElement(NAME_ELEMENT,params[i].getSimpleName());
  +      writeValueElement(TYPE_ELEMENT,params[i].getType().getQualifiedName());
  +      writeAnnotatedElement(params[i]);
  +      mOut.writeEndElement();
  +    }
  +    writeAnnotatedElement(ji);
  +  }
  +
  +  private void writeClassList(String elementName, JClass[] clazzes)
  +    throws XMLStreamException
  +  {
  +    for(int i=0; i<clazzes.length; i++) {
  +      mOut.writeStartElement(elementName);
  +      mOut.writeCharacters(clazzes[i].getQualifiedName());
  +      mOut.writeEndElement();
  +    }
  +  }
  +
  +  private void writeModifiers(int mods) throws XMLStreamException {
  +    mOut.writeStartElement(MODIFIERS_ELEMENT);
  +    mOut.writeCharacters(String.valueOf(mods));
  +    mOut.writeEndElement();
  +  }
  +
  +  private void writeValueElement(String elementName, boolean b)
  +    throws XMLStreamException
  +  {
  +    mOut.writeStartElement(elementName);
  +    mOut.writeCharacters(String.valueOf(b));
  +    mOut.writeEndElement();
  +  }
  +
  +  private void writeValueElement(String elementName, int x)
  +    throws XMLStreamException
  +  {
  +    mOut.writeStartElement(elementName);
  +    mOut.writeCharacters(String.valueOf(x));
  +    mOut.writeEndElement();
  +  }
  +
  +  private void writeValueElement(String elementName, String val)
  +    throws XMLStreamException
  +  {
  +    mOut.writeStartElement(elementName);
  +    mOut.writeCharacters(val);
  +    mOut.writeEndElement();
  +  }
  +
  +  private void writeAnnotatedElement(JAnnotatedElement ae)
  +    throws XMLStreamException
  +  {
  +    JAnnotation[] anns = ae.getAnnotations();
  +    for(int i=0; i<anns.length; i++) {
  +      writeAnnotation(anns[i]);
  +    }
  +    JComment jc = ae.getComment();
  +    if (jc != null) {
  +      String text = jc.getText();
  +      if (text != null) {
  +        text = text.trim();
  +        if (text.length() > 0) {
  +          mOut.writeStartElement(COMMENT_ELEMENT);
  +          mOut.writeCData(jc.getText());
  +          mOut.writeEndElement();
  +        }
  +      }
  +    }
  +    JSourcePosition pos = ae.getSourcePosition();
  +    if (pos != null) {
  +      mOut.writeStartElement(SOURCEPOSITION_ELEMENT);
  +      if (pos.getLine() != -1) {
  +        writeValueElement(LINE_ELEMENT,pos.getLine());
  +      }
  +      if (pos.getColumn() != -1) {
  +        writeValueElement(COLUMN_ELEMENT,pos.getColumn());
  +      }
  +      if (pos.getSourceURI() != null)
  +        writeValueElement(SOURCEURI_ELEMENT,pos.getSourceURI().toString());
  +      mOut.writeEndElement();
  +    }
  +  }
  +
  +  private void writeAnnotation(JAnnotation ann) throws XMLStreamException {
  +    mOut.writeStartElement(ANNOTATION_ELEMENT);
  +    writeValueElement(NAME_ELEMENT,ann.getSimpleName());
  +    JAnnotationValue[] values = ann.getValues();
  +    for(int i=0; i<values.length; i++) {
  +      writeAnnotationValue(values[i]);
  +    }
  +  }
  +
  +  private void writeAnnotationValue(JAnnotationValue val)
  +    throws XMLStreamException
  +  {
  +    mOut.writeStartElement(ANNOTATIONVALUE_ELEMENT);
  +    writeValueElement(NAME_ELEMENT,val.getName());
  +
  +writeValueElement(VALUE_ELEMENT,val.asString());
  +    //FIXME what about asAnnotationArray?
  +/*    JAnnotation nestedAnn = val.asAnnotation();
  +    if (nestedAnn != null) {
  +      writeAnnotation(nestedAnn);
  +    } else {
  +      writeValueElement(VALUE_ELEMENT,val.asString());
  +    }
  +    */
  +  }
  +}
  \ No newline at end of file
  
  
  
  1.6       +10 -29    xml-xmlbeans/v2/jam/test/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/build.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- build.xml	10 Mar 2004 11:42:08 -0000	1.5
  +++ build.xml	16 Mar 2004 05:34:50 -0000	1.6
  @@ -5,18 +5,25 @@
     <property name='src-jamtest' value='.' />
     <property name='jamroot' value='../' />
      
  -  <property name='build_dir' value='${jamroot}/build'/>
  +  <property name='build_dir' value='${jamroot}/../build/jam'/> <!--FIXME-->
     <property name='test_build_dir' value='${build_dir}/test'/>
     <property name='dummy_dir' value='${test_build_dir}/dummyclasses'/>
     <property name='junit_jar' value='${jamroot}/external/lib/junit.jar' />
  +  <property name='jsr173api_jar' value='../../build/lib/jsr173_api.jar'/>
  +  <property name='jsr173ri_jar' value='../../build/lib/jsr173_ri.jar'/>
  +
   
     <path id='classpath' >
   
    <!-- use build/classes instead of xbean.jar for develpment convenience -->
  -    <pathelement path='${jamroot}/build/classes' />
  +    <pathelement path='${build_dir}/classes' />
       <pathelement location='${test_build_dir}' />
       <pathelement location='${junit_jar}'/>
       <pathelement path='${java.class.path}' />
  +
  +    <pathelement location='${jsr173api_jar}' />
  +    <pathelement location='${jsr173ri_jar}' />
  +
     </path>
   
     <property name='classpath-value' refid='classpath'/>
  @@ -33,6 +40,7 @@
        />
       <mkdir dir='${dummy_dir}'/>
       <javac
  +       source='1.5' target='1.5'
          srcdir='dummyclasses'
          destdir='${dummy_dir}'
          classpathref='classpath'
  @@ -68,33 +76,6 @@
       </junit>
     </target>
   
  -
  -  <!-- JDK 1.5-specific tests.  These have to be run manually since we
  -       don't require 1.5 yet -->
  -
  -  <target name='tiger' depends='tiger.build,tiger.run'/>
  -
  -  <target name='tiger.clean' >
  -    <delete dir='${dummy_dir}'/>
  -  </target>
  -
  -  <target name='tiger.build' >
  -    <mkdir dir='${dummy_dir}'/>
  -    <javac
  -       source='1.5'
  -       srcdir='dummy15classes'
  -       destdir='${dummy_dir}'
  -       classpathref='classpath'
  -       includes='**/*.java'
  -       fork='true'
  -
  -      executable='e:/java/jdk150/bin/javac.exe'
  -      verbose='true'
  -      target='1.5'
  -     />
  -  </target>
  -
  -  <target name='tiger.run'/>
   
   </project>
   
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/AnnotatedClass.java
  
  Index: AnnotatedClass.java
  ===================================================================
  package org.apache.xmlbeans.test.jam.dummyclasses.jsr175;
  
  
  @RFEAnnotation(
      id       = 4561414,
      synopsis = "Balance the federal budget"
  )
  public abstract class AnnotatedClass {
  
    public abstract void setFoo(int value);
  
    public abstract int getFoo();
  }
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/RFEAnnotation.java
  
  Index: RFEAnnotation.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.test.jam.dummyclasses.jsr175;
  
  import java.lang.annotation.*;
  
  /**
   *
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  @Retention(RetentionPolicy.RUNTIME)
  @Target(ElementType.TYPE)
  public @interface RFEAnnotation {
      int    id();        // Unique ID number associated with RFE
      String synopsis();  // Synopsis of RFE
      String engineer()  default "[unassigned]";
      String date()      default "[unimplemented]";
  }
  
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/jsr175/RFEAnnotationImpl.java
  
  Index: RFEAnnotationImpl.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.test.jam.dummyclasses.jsr175;
  
  /**
   *
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public class RFEAnnotationImpl implements RFEAnnotation {
  
    public int    id() { return 0;}
    public String synopsis() { return null;}
    public String engineer() { return null; }
    public String date() { return null;}
  
    public java.lang.Class annotationType() { return getClass(); }
  
  }
  
  
  
  1.6       +1 -1      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ClassesJamTest.java
  
  Index: ClassesJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ClassesJamTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ClassesJamTest.java	10 Mar 2004 11:42:09 -0000	1.5
  +++ ClassesJamTest.java	16 Mar 2004 05:34:50 -0000	1.6
  @@ -83,7 +83,7 @@
       JamServiceParams params = jsf.createServiceParams();
   //include
       params.includeClassFiles(getDummyclassesClassDir(),"**/*.class");
  -    //params.setVerbose(true);
  +    params.setVerbose(true);
       return jsf.createService(params);
     }
   
  
  
  
  1.6       +44 -11    xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
  
  Index: JamTestBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JamTestBase.java	10 Mar 2004 11:42:09 -0000	1.5
  +++ JamTestBase.java	16 Mar 2004 05:34:50 -0000	1.6
  @@ -57,8 +57,16 @@
   
   import junit.framework.TestCase;
   import org.apache.xmlbeans.impl.jam.*;
  +import org.apache.xmlbeans.impl.jam.xml.JamXmlWriter;
   
  +import javax.xml.stream.XMLStreamException;
  +import javax.xml.stream.XMLInputFactory;
  +import javax.xml.stream.XMLStreamReader;
   import java.io.File;
  +import java.io.FileWriter;
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import java.io.Writer;
   import java.util.*;
   
   /**
  @@ -82,16 +90,21 @@
     //this array must contain the names of all of the test classes under
     //dummyclasses
     private static final String[] ALL_CLASSES = {
  -   DUMMY+".ejb.IEnv",
  -   DUMMY+".ejb.MyEjbException",
  -   DUMMY+".ejb.TraderEJB",
  -   DUMMY+".ejb.TradeResult",
  -   DUMMY+".Base",
  -   DUMMY+".Baz",
  -   DUMMY+".Foo",
  -   DUMMY+".FooImpl",
  -   DUMMY+".HeavilyCommented",
  -   DUMMY+".MyException"
  +    DUMMY+".ejb.IEnv",
  +    DUMMY+".ejb.MyEjbException",
  +    DUMMY+".ejb.TraderEJB",
  +    DUMMY+".ejb.TradeResult",
  +
  +    DUMMY+".jsr175.AnnotatedClass",
  +    DUMMY+".jsr175.RFEAnnotation",
  +    DUMMY+".jsr175.RFEAnnotationImpl",
  +
  +    DUMMY+".Base",
  +    DUMMY+".Baz",
  +    DUMMY+".Foo",
  +    DUMMY+".FooImpl",
  +    DUMMY+".HeavilyCommented",
  +    DUMMY+".MyException"
     };
   
   
  @@ -188,7 +201,7 @@
      * Returns the directory into which the dummyclasses have been compiled.
      */
     protected File getDummyclassesClassDir() {
  -    return new File("../build/test/dummyclasses");
  +    return new File("../../build/jam/test/dummyclasses");
     }
   
     // ========================================================================
  @@ -214,6 +227,26 @@
                  classNames.containsAll(expected));
       assertTrue("result contains more than expected classes",
                  expected.containsAll(classNames));
  +  }
  +
  +  private void dump(JClass j) {
  +    Writer out = new PrintWriter(System.out,true);
  +    JamXmlWriter jxw = null;
  +    try {
  +      jxw = new JamXmlWriter(out);
  +      jxw.write(j);
  +      out.flush();
  +    } catch (IOException e) {
  +      e.printStackTrace();
  +    } catch (XMLStreamException e) {
  +      e.printStackTrace();
  +    }
  +  }
  +
  +
  +  public void test175Annotations() throws IOException, XMLStreamException {
  +    JClass clazz = resolved(mLoader.loadClass(DUMMY+".jsr175.AnnotatedClass"));
  +    dump(clazz);
     }
   
     public void testRecursiveResolve() {
  
  
  
  1.4       +2 -0      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java
  
  Index: SourcesJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SourcesJamTest.java	9 Mar 2004 10:38:54 -0000	1.3
  +++ SourcesJamTest.java	16 Mar 2004 05:34:50 -0000	1.4
  @@ -58,6 +58,7 @@
   import org.apache.xmlbeans.impl.jam.JamServiceFactory;
   import org.apache.xmlbeans.impl.jam.JamServiceParams;
   import org.apache.xmlbeans.impl.jam.JamService;
  +import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocClassBuilder;
   
   import java.io.IOException;
   
  @@ -82,6 +83,7 @@
       JamServiceFactory jsf = JamServiceFactory.getInstance();
       JamServiceParams params = jsf.createServiceParams();
       params.includeSourceFiles(getDummyclassesSourceRoot(),"**/*.java");
  +    params.setProperty(JavadocClassBuilder.ARGS_PROPERTY,"-source 1.5");
       return jsf.createService(params);
     }
   
  
  
  

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