db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r611331 - in /db/jdo/trunk/tck2/src: conf/jdo-2_1-signatures.txt java/org/apache/jdo/tck/util/signature/Formatter.java java/org/apache/jdo/tck/util/signature/SignatureVerifier.java
Date Fri, 11 Jan 2008 23:37:20 GMT
Author: clr
Date: Fri Jan 11 15:37:13 2008
New Revision: 611331

URL: http://svn.apache.org/viewvc?rev=611331&view=rev
Log:
JDO-565 Add signature tests for annotations and enums
The SignatureVerifier class is now dependent on Java 5
so it is not the same as tck2-legacy.

Modified:
    db/jdo/trunk/tck2/src/conf/jdo-2_1-signatures.txt
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/Formatter.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java

Modified: db/jdo/trunk/tck2/src/conf/jdo-2_1-signatures.txt
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/conf/jdo-2_1-signatures.txt?rev=611331&r1=611330&r2=611331&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/conf/jdo-2_1-signatures.txt (original)
+++ db/jdo/trunk/tck2/src/conf/jdo-2_1-signatures.txt Fri Jan 11 15:37:13 2008
@@ -459,7 +459,7 @@
     public static boolean isNew(Object pc);
     public static boolean isDeleted(Object pc);
     public static boolean isDetached(Object pc);
-    public static javax.jdo.ObjectState getObjectState(Object pc);
+    public static enum javax.jdo.ObjectState getObjectState(Object pc);
     public static javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory();
     public static javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map
props);
     public static javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map
props, ClassLoader cl);
@@ -616,7 +616,7 @@
     public void evict(Object pc);
     public varargs void evictAll(Object[] pcs);
     public void evictAll(java.util.Collection pcs);
-    public void evictAll(java.lang.Class, boolean);
+    public void evictAll(Class, boolean);
     public void evictAll();
     public void refresh(Object pc);
     public varargs void refreshAll(Object[] pcs);
@@ -1036,4 +1036,462 @@
     public void setSynchronization(javax.transaction.Synchronization sync);
     public javax.transaction.Synchronization getSynchronization();
     public javax.jdo.PersistenceManager getPersistenceManager();
+}
+
+public final enum javax.jdo.ObjectState extends java.lang.Enum {
+
+    public static final enum javax.jdo.ObjectState TRANSIENT;
+    public static final enum javax.jdo.ObjectState TRANSIENT_CLEAN;
+    public static final enum javax.jdo.ObjectState TRANSIENT_DIRTY;
+    public static final enum javax.jdo.ObjectState PERSISTENT_NEW;
+    public static final enum javax.jdo.ObjectState HOLLOW_PERSISTENT_NONTRANSACTIONAL;
+    public static final enum javax.jdo.ObjectState PERSISTENT_NONTRANSACTIONAL_DIRTY;
+    public static final enum javax.jdo.ObjectState PERSISTENT_CLEAN;
+    public static final enum javax.jdo.ObjectState PERSISTENT_DIRTY;
+    public static final enum javax.jdo.ObjectState PERSISTENT_DELETED;
+    public static final enum javax.jdo.ObjectState PERSISTENT_NEW_DELETED;
+    public static final enum javax.jdo.ObjectState DETACHED_CLEAN;
+    public static final enum javax.jdo.ObjectState DETACHED_DIRTY;
+    public static enum javax.jdo.ObjectState valueOf(java.lang.String);
+    public static final javax.jdo.ObjectState[] values();
+    public String toString();
+}
+
+public annotation javax.jdo.annotations.Column extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String target() default "";
+    String targetMember() default "";
+    String jdbcType() default "";
+    String sqlType() default "";
+    int length() default -1;
+    int scale() default -1;
+    String allowsNull() default "";
+    String defaultValue() default "";
+    String insertValue() default "";
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.Columns extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Column[] value();
+}
+
+public annotation javax.jdo.annotations.DatastoreIdentity extends java.lang.annotation.Annotation
+{
+    enum javax.jdo.annotations.IdGeneratorStrategy strategy() default javax.jdo.annotations.IdGeneratorStrategy.UNSPECIFIED;
+    String customStrategy() default "";
+    String sequence() default "";
+    String column() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.Discriminator extends java.lang.annotation.Annotation
+{
+    enum javax.jdo.annotations.DiscriminatorStrategy strategy() 
+        default javax.jdo.annotations.DiscriminatorStrategy.UNSPECIFIED;
+    String customStrategy() default "";
+    String indexed() default "";
+    String column() default "";
+    String value() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+}
+
+public final enum javax.jdo.annotations.DiscriminatorStrategy extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.DiscriminatorStrategy UNSPECIFIED;
+    public static final enum javax.jdo.annotations.DiscriminatorStrategy NONE;
+    public static final enum javax.jdo.annotations.DiscriminatorStrategy VALUE_MAP;
+    public static final enum javax.jdo.annotations.DiscriminatorStrategy CLASS_NAME;
+    public static enum javax.jdo.annotations.DiscriminatorStrategy valueOf(java.lang.String);
+    public static final javax.jdo.annotations.DiscriminatorStrategy[] values();
+}
+
+public annotation javax.jdo.annotations.Element extends java.lang.annotation.Annotation
+{
+    Class[] types() default {};
+    String serialized() default "";
+    String embedded() default "";
+    javax.jdo.annotations.Embedded[] embeddedMapping() default {};
+    String dependent() default "";
+    String table() default "";
+    String column() default "";
+    enum javax.jdo.annotations.ForeignKeyAction deleteAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    enum javax.jdo.annotations.ForeignKeyAction updateAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    String indexed() default "";
+    String index() default "";
+    String unique() default "";
+    String uniqueKey() default "";
+    String mappedBy() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+    String generateForeignKey() default "";
+    String foreignKey() default "";
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.Embedded extends java.lang.annotation.Annotation
+{
+    String ownerMember() default "";
+    String nullIndicatorColumn() default "";
+    String nullIndicatorValue() default "";
+    javax.jdo.annotations.Persistent[] members() default {};
+}
+
+public annotation javax.jdo.annotations.EmbeddedOnly extends java.lang.annotation.Annotation
+{
+}
+
+public annotation javax.jdo.annotations.Extension extends java.lang.annotation.Annotation
+{
+    String vendorName();
+    String key();
+    String value();
+}
+
+public annotation javax.jdo.annotations.Extensions extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Extension[] value();
+}
+
+public annotation javax.jdo.annotations.FetchGroup extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String postLoad() default "";
+    javax.jdo.annotations.Persistent[] members();
+    String[] fetchGroups() default {};
+}
+
+public annotation javax.jdo.annotations.FetchGroups extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.FetchGroup[] value();
+}
+
+public annotation javax.jdo.annotations.FetchPlan extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String[] fetchGroups() default {};
+    int maxFetchDepth() default 1;
+    int fetchSize() default 0;
+}
+
+public annotation javax.jdo.annotations.FetchPlans extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.FetchPlan[] value();
+}
+
+public annotation javax.jdo.annotations.ForeignKey extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String table() default "";
+    String deferred() default "";
+    String unique() default "";
+    enum javax.jdo.annotations.ForeignKeyAction deleteAction() default javax.jdo.annotations.ForeignKeyAction.RESTRICT;
+    enum javax.jdo.annotations.ForeignKeyAction updateAction() default javax.jdo.annotations.ForeignKeyAction.RESTRICT;
+    String[] members() default {};
+    javax.jdo.annotations.Column[] columns() default {};
+}
+
+public final enum javax.jdo.annotations.ForeignKeyAction extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.ForeignKeyAction UNSPECIFIED;
+    public static final enum javax.jdo.annotations.ForeignKeyAction RESTRICT;
+    public static final enum javax.jdo.annotations.ForeignKeyAction CASCADE;
+    public static final enum javax.jdo.annotations.ForeignKeyAction NULL;
+    public static final enum javax.jdo.annotations.ForeignKeyAction DEFAULT;
+    public static final enum javax.jdo.annotations.ForeignKeyAction NONE;
+    public static enum javax.jdo.annotations.ForeignKeyAction valueOf(java.lang.String);
+    public static final javax.jdo.annotations.ForeignKeyAction[] values();
+}
+
+public annotation javax.jdo.annotations.ForeignKeys extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.ForeignKey[] value();
+}
+
+public final enum javax.jdo.annotations.IdGeneratorStrategy extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy UNSPECIFIED;
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy NATIVE;
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy SEQUENCE;
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy IDENTITY;
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy INCREMENT;
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy UUIDSTRING;
+    public static final enum javax.jdo.annotations.IdGeneratorStrategy UUIDHEX;
+    public static enum javax.jdo.annotations.IdGeneratorStrategy valueOf(java.lang.String);
+    public static final javax.jdo.annotations.IdGeneratorStrategy[] values();
+}
+
+public final enum javax.jdo.annotations.IdentityType extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.IdentityType UNSPECIFIED;
+    public static final enum javax.jdo.annotations.IdentityType APPLICATION;
+    public static final enum javax.jdo.annotations.IdentityType DATASTORE;
+    public static final enum javax.jdo.annotations.IdentityType NONDURABLE;
+    public static enum javax.jdo.annotations.IdentityType valueOf(java.lang.String);
+    public static final javax.jdo.annotations.IdentityType[] values();
+}
+
+public annotation javax.jdo.annotations.Index extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String table() default "";
+    String unique() default "";
+    String[] members() default {};
+    javax.jdo.annotations.Column[] columns() default {};
+}
+
+public annotation javax.jdo.annotations.Indices extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Index[] value();
+}
+
+public annotation javax.jdo.annotations.Inheritance extends java.lang.annotation.Annotation
+{
+    enum javax.jdo.annotations.InheritanceStrategy strategy() default javax.jdo.annotations.InheritanceStrategy.UNSPECIFIED;
+    String customStrategy() default "";
+}
+
+public final enum javax.jdo.annotations.InheritanceStrategy extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.InheritanceStrategy UNSPECIFIED;
+    public static final enum javax.jdo.annotations.InheritanceStrategy NEW_TABLE;
+    public static final enum javax.jdo.annotations.InheritanceStrategy SUBCLASS_TABLE;
+    public static final enum javax.jdo.annotations.InheritanceStrategy SUPERCLASS_TABLE;
+    public static enum javax.jdo.annotations.InheritanceStrategy valueOf(java.lang.String);
+    public static final javax.jdo.annotations.InheritanceStrategy[] values();
+}
+
+public annotation javax.jdo.annotations.Join extends java.lang.annotation.Annotation
+{
+    String table() default "";
+    String column() default "";
+    String indexed() default "";
+    String index() default "";
+    String unique() default "";
+    String uniqueKey() default "";
+    String outer() default "";
+    enum javax.jdo.annotations.ForeignKeyAction deleteAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    javax.jdo.annotations.Column[] columns() default {};
+    String generatePrimaryKey() default "";
+    String primaryKey() default "";
+    String generateForeignKey() default "";
+    String foreignKey() default "";
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.Joins extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Join[] value();
+}
+
+public annotation javax.jdo.annotations.Key extends java.lang.annotation.Annotation
+{
+    Class[] types() default {};
+    String serialized() default "";
+    String embedded() default "";
+    javax.jdo.annotations.Embedded[] embeddedMapping() default {};
+    String dependent() default "";
+    String table() default "";
+    String column() default "";
+    enum javax.jdo.annotations.ForeignKeyAction deleteAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    enum javax.jdo.annotations.ForeignKeyAction updateAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    String indexed() default "";
+    String index() default "";
+    String unique() default "";
+    String uniqueKey() default "";
+    String mappedBy() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+    String generateForeignKey() default "";
+    String foreignKey() default "";
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.NotPersistent extends java.lang.annotation.Annotation
+{
+}
+
+public final enum javax.jdo.annotations.NullValue extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.NullValue NONE;
+    public static final enum javax.jdo.annotations.NullValue EXCEPTION;
+    public static final enum javax.jdo.annotations.NullValue DEFAULT;
+    public static enum javax.jdo.annotations.NullValue valueOf(java.lang.String);
+    public static final javax.jdo.annotations.NullValue[] values();
+}
+
+public annotation javax.jdo.annotations.Order extends java.lang.annotation.Annotation
+{
+    String column() default "";
+    String mappedBy() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+}
+
+public annotation javax.jdo.annotations.PersistenceAware extends java.lang.annotation.Annotation
+{
+}
+
+public annotation javax.jdo.annotations.PersistenceCapable extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Persistent[] members() default {};
+    String table() default "";
+    String catalog() default "";
+    String schema() default "";
+    String requiresExtent() default "";
+    String embeddedOnly() default "";
+    String detachable() default "";
+    enum javax.jdo.annotations.IdentityType identityType() default javax.jdo.annotations.IdentityType.UNSPECIFIED;
+    Class objectIdClass() default void.class;
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public final enum javax.jdo.annotations.PersistenceModifier extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.PersistenceModifier UNSPECIFIED;
+    public static final enum javax.jdo.annotations.PersistenceModifier PERSISTENT;
+    public static final enum javax.jdo.annotations.PersistenceModifier TRANSACTIONAL;
+    public static final enum javax.jdo.annotations.PersistenceModifier NONE;
+    public static enum javax.jdo.annotations.PersistenceModifier valueOf(java.lang.String);
+    public static final javax.jdo.annotations.PersistenceModifier[] values();
+}
+
+public annotation javax.jdo.annotations.Persistent extends java.lang.annotation.Annotation
+{
+    enum javax.jdo.annotations.PersistenceModifier persistenceModifier() 
+        default javax.jdo.annotations.PersistenceModifier.UNSPECIFIED;
+    String table() default "";
+    String defaultFetchGroup() default "";
+    enum javax.jdo.annotations.NullValue nullValue() default javax.jdo.annotations.NullValue.NONE;
+    String embedded() default "";
+    String embeddedElement() default "";
+    String embeddedKey() default "";
+    String embeddedValue() default "";
+    String serialized() default "";
+    String serializedElement() default "";
+    String serializedKey() default "";
+    String serializedValue() default "";
+    String dependent() default "";
+    String dependentElement() default "";
+    String dependentKey() default "";
+    String dependentValue() default "";
+    String primaryKey() default "";
+    enum javax.jdo.annotations.IdGeneratorStrategy valueStrategy() default javax.jdo.annotations.IdGeneratorStrategy.UNSPECIFIED;
+    String customValueStrategy() default "";
+    String sequence() default "";
+    String loadFetchGroup() default "";
+    Class[] types() default {};
+    String mappedBy() default "";
+    javax.jdo.annotations.Column[] columns() default {}; 
+    String column() default "";
+    String nullIndicatorColumn() default "";
+    String name() default ""; 
+    int recursionDepth() default 1;
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.PrimaryKey extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String column() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+}
+
+public annotation javax.jdo.annotations.Queries extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Query[] value();
+}
+
+public annotation javax.jdo.annotations.Query extends java.lang.annotation.Annotation
+{
+    String name();
+    String value();
+    String language() default "JDOQL";
+    String unmodifiable() default "";
+    String unique() default "";
+    Class resultClass() default void.class;
+    String fetchPlan() default "";
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.Sequence extends java.lang.annotation.Annotation
+{
+    String name();
+    enum javax.jdo.annotations.SequenceStrategy strategy();
+    String datastoreSequence() default "";
+    Class factoryClass() default void.class;
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public final enum javax.jdo.annotations.SequenceStrategy extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.SequenceStrategy NONTRANSACTIONAL;
+    public static final enum javax.jdo.annotations.SequenceStrategy CONTIGUOUS;
+    public static final enum javax.jdo.annotations.SequenceStrategy NONCONTIGUOUS;
+    public static enum javax.jdo.annotations.SequenceStrategy valueOf(java.lang.String);
+    public static final javax.jdo.annotations.SequenceStrategy[] values();
+}
+
+public annotation javax.jdo.annotations.Serialized extends java.lang.annotation.Annotation
+{
+}
+
+public annotation javax.jdo.annotations.Transactional extends java.lang.annotation.Annotation
+{
+}
+
+public annotation javax.jdo.annotations.Unique extends java.lang.annotation.Annotation
+{
+    String name() default "";
+    String table() default "";
+    String deferred() default "";
+    String[] members() default {};
+    javax.jdo.annotations.Column[] columns() default {};
+}
+
+public annotation javax.jdo.annotations.Uniques extends java.lang.annotation.Annotation
+{
+    javax.jdo.annotations.Unique[] value();
+}
+
+public annotation javax.jdo.annotations.Value extends java.lang.annotation.Annotation
+{
+    Class[] types() default {};
+    String serialized() default "";
+    String embedded() default "";
+    javax.jdo.annotations.Embedded[] embeddedMapping() default {};
+    String dependent() default "";
+    String table() default "";
+    String column() default "";
+    enum javax.jdo.annotations.ForeignKeyAction deleteAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    enum javax.jdo.annotations.ForeignKeyAction updateAction() default javax.jdo.annotations.ForeignKeyAction.UNSPECIFIED;
+    String indexed() default "";
+    String index() default "";
+    String unique() default "";
+    String uniqueKey() default "";
+    String mappedBy() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+    String generateForeignKey() default "";
+    String foreignKey() default "";
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public annotation javax.jdo.annotations.Version extends java.lang.annotation.Annotation
+{
+    enum javax.jdo.annotations.VersionStrategy strategy() default javax.jdo.annotations.VersionStrategy.UNSPECIFIED;
+    String customStrategy() default "";
+    String column() default "";
+    String indexed() default "";
+    javax.jdo.annotations.Column[] columns() default {};
+    javax.jdo.annotations.Extension[] extensions() default {};
+}
+
+public final enum javax.jdo.annotations.VersionStrategy extends java.lang.Enum
+{
+    public static final enum javax.jdo.annotations.VersionStrategy UNSPECIFIED;
+    public static final enum javax.jdo.annotations.VersionStrategy NONE;
+    public static final enum javax.jdo.annotations.VersionStrategy STATE_IMAGE;
+    public static final enum javax.jdo.annotations.VersionStrategy DATE_TIME;
+    public static final enum javax.jdo.annotations.VersionStrategy VERSION_NUMBER;
+    public static enum javax.jdo.annotations.VersionStrategy valueOf(java.lang.String);
+    public static final javax.jdo.annotations.VersionStrategy[] values();
 }

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/Formatter.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/Formatter.java?rev=611331&r1=611330&r2=611331&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/Formatter.java (original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/Formatter.java Fri Jan 11
15:37:13 2008
@@ -115,6 +115,9 @@
         s.append(method.getName()).append("(");
         s.append(toString("", method.getParameterTypes())).append(")");
         s.append(toString(" throws ", method.getExceptionTypes()));
+        if (method.getDeclaringClass().isAnnotation() && method.getDefaultValue()
!= null) {
+            s.append(" default \"" + method.getDefaultValue() + "\"");
+        }
         return s.toString();
     }
 

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java?rev=611331&r1=611330&r2=611331&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java (original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java Fri
Jan 11 15:37:13 2008
@@ -17,6 +17,7 @@
 
 package org.apache.jdo.tck.util.signature;
 
+import java.lang.reflect.Array;
 import java.lang.reflect.Member;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Field;
@@ -49,6 +50,30 @@
     /** The new-line character on this system. */
     static protected final String NL = System.getProperty("line.separator");
 
+    /** All modifiers defined in java.lang.reflect.Modifier.
+     * This field is used to filter out vm-specific modifiers 
+     * such as found in Sun's vm to identify Enum and Annotation.
+     */
+    static protected final int ALL_MODIFIERS = 
+            Modifier.ABSTRACT |
+            Modifier.FINAL |
+            Modifier.INTERFACE |
+            Modifier.NATIVE |
+            Modifier.PRIVATE |
+            Modifier.PROTECTED |
+            Modifier.PUBLIC |
+            Modifier.STATIC |
+            Modifier.STRICT |
+            Modifier.SYNCHRONIZED |
+            Modifier.TRANSIENT |
+            Modifier.VOLATILE;
+
+    /** Pseudo modifier for annotation */
+    static protected final int ANNOTATION = 0x2000;
+
+    /** Pseudo modifier for enum */
+    static protected final int ENUM = 0x4000;
+
     /** A writer for standard output. */
     protected final PrintWriter log;
 
@@ -107,7 +132,7 @@
     public SignatureVerifier(PrintWriter log,
                              boolean quiet, boolean verbose) {
         this(SignatureVerifier.class.getClassLoader(), log, quiet, verbose);
-    }    
+    }
 
     // ----------------------------------------------------------------------
     // Local Logging Methods
@@ -279,6 +304,142 @@
         return cls;
     }
 
+    /** Check an expected value expression (the value of a static field
+     *  or the default value of an annotation method), comparing it to
+     *  the actual value from the Field or Method object.
+     *  Only supports primitive, enum, empty array of enum, empty array of
+     *  annotation, and String.
+     * @param value the String form of the value from the signature file
+     * @param type the type as declared in the class
+     * @param actual the actual value
+     * @return the description of the expected value, or null if ok
+     * @throws java.lang.NumberFormatException
+     */
+    protected String checkValue(String value, String type, Object actual) 
+            throws NumberFormatException {
+        // note array type
+        boolean isArray = false;
+        if (type.endsWith("[]")) {
+            isArray = true;
+            type = type.substring(0, type.length() - 2);
+            // remove { from beginning and } from end
+            value = value.substring(1, value.length() - 1);
+        }
+        // first check primitive type
+        final Object exp;
+        Class expClass;
+        final boolean ok;
+        if (type.equals("byte")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(byte.class);
+            } else {
+                ok = Byte.valueOf(value).equals(actual);
+            }
+        } else if (type.equals("short")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(short.class);
+            } else {
+                ok = Short.valueOf(value).equals(actual);
+            }
+        } else if (type.equals("int")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(int.class);
+            } else {
+                ok = Integer.valueOf(value).equals(actual);
+            }
+        } else if (type.equals("long")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(long.class);
+            } else {
+                ok = Long.valueOf(value).equals(actual);
+            }
+        } else if (type.equals("float")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(float.class);
+            } else {
+                ok = Float.valueOf(value).equals(actual);
+            }
+        } else if (type.equals("double")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(double.class);
+            } else {
+                ok = Double.valueOf(value).equals(actual);
+            }
+        } else if (type.equals("char")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(char.class);
+            } else {
+                ok = new Character(value.charAt(1)).equals(actual);
+            }
+        // next check Class
+        } else if (type.equals("java.lang.Class")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(Class.class);
+            } else {
+                // strip ".class" from type name
+                int offset = value.indexOf(".class");
+                value = value.substring(0, offset);
+                ok = getClass(value).equals(actual);
+            }
+        // next check String
+        } else if (type.equals("java.lang.String")) {
+            if (isArray) {
+                ok = actual.getClass().getComponentType().equals(String.class);
+            } else {
+                // cut off '\"' chars at begin and end
+                final String s;
+                if (value.length() > 1) {
+                    s = value.substring(1, value.length() - 1);
+                } else {
+                    s = "";
+                }
+                ok = (String.valueOf(s)).equals(actual);
+            }
+        // now check non-java.lang annotations and enums
+        } else {
+            expClass = getClass(type);
+            if (isArray) {
+                // check if the actual component type is the right class
+                // don't check the actual values because only empty arrays
+                // are supported.
+                ok = actual.getClass().getComponentType().equals(expClass);
+            } else {
+                // get the actual value which must be a static class.field
+                Object expectedValue = null;
+                try {
+                    // now get actual value
+                    // separate value name into class and field name
+                    int lastDot = value.lastIndexOf(".");
+                    String expectedClassName = value.substring(0, lastDot);
+                    String expectedFieldName = 
+                            value.substring(lastDot + 1, value.length());
+                    // get Class object from class name
+                    Class expectedClass = getClass(expectedClassName);
+                    if (expectedClass == null) 
+                        throw new ClassNotFoundException();
+                    // get Field object from Class and field name
+                    Field expectedField = 
+                            expectedClass.getField(expectedFieldName);
+                    expectedValue = expectedField.get(null);
+                } catch (NoSuchFieldException ex) {
+                    handleNotLoading(ex);
+                } catch (SecurityException ex) {
+                    handleNotLoading(ex);
+                } catch (IllegalArgumentException ex) {
+                    handleNotLoading(ex);
+                } catch (IllegalAccessException ex) {
+                    handleNotLoading(ex);
+                } catch (ClassNotFoundException ex) {
+                    handleNotLoading(ex);
+                }
+                ok = expectedValue.equals(actual);
+            }
+        }
+        // return message if not ok
+        if (ok) return null;
+        else return value;
+    }
+
     /** Validates a field against a prescribed signature. */
     protected void checkField(int mods, String type, String name,
                               String value) {
@@ -306,7 +467,7 @@
             mods |= Modifier.STATIC;
             mods |= Modifier.FINAL;
         }
-        if (mods != field.getModifiers()) {
+        if (mods != convertModifiers(field)) {
             handleMismatch(
                 "field declaration: non-matching modifiers;",
                 Formatter.toString(mods, type, name, null),
@@ -322,7 +483,7 @@
         }
 
         // check field value if any
-        Object fieldValue = null;
+        Object actualValue = null;
         if (value != null) {
             // only support for public, static, and final fields
             final int m = (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL);
@@ -331,51 +492,27 @@
                               + "definition in descriptor file;",
                               Formatter.toString(mods, type, name, value));
             } else {
-                // only support for primitive types and String
-                final Object exp;
-                if (type.equals("byte")) {
-                    exp = Byte.valueOf(value);
-                } else if (type.equals("short")) {
-                    exp = Short.valueOf(value);
-                } else if (type.equals("integer")) {
-                    exp = Integer.valueOf(value);
-                } else if (type.equals("long")) {
-                    exp = Long.valueOf(value);
-                } else if (type.equals("float")) {
-                    exp = Float.valueOf(value);
-                } else if (type.equals("double")) {
-                    exp = Double.valueOf(value);
-                } else if (type.equals("char")) {
-                    // cut off '\'' char at begin and end
-                    exp = new Character(value.charAt(1));
-                } else if (type.equals("java.lang.String")) {
-                    // cut off '\"' chars at begin and end
-                    final String s = value.substring(1, value.length() - 1);
-                    exp = String.valueOf(s);
-                } else {
-                    exp = null;
-                }
-
                 // compare field's expected with found value
                 try {
-                    fieldValue = field.get(null);
+                    actualValue = field.get(null);
                 } catch (IllegalAccessException ex) {
                     handleProblem("field declaration: cannot access field "
                                   + "value, exception: " + ex + ";",
                                   Formatter.toString(mods, type, name, value));
                 }
-                if (exp != null && !exp.equals(fieldValue)) {
+                String error = checkValue(value, type, actualValue);
+                if (error != null) {
                     handleMismatch(
                         "field declaration: non-matching values;",
-                        Formatter.toString(mods, type, name, exp.toString()),
-                        Formatter.toString(field, fieldValue));
+                        Formatter.toString(mods, type, name, error),
+                        Formatter.toString(field, "\"" + actualValue + "\""));
                 }
             }
         }
         
         // field OK
         members.remove(field);
-        handleMatch("has field: ", Formatter.toString(field, fieldValue));
+        handleMatch("has field: ", Formatter.toString(field, actualValue));
     }
 
     /** Validates a constructor against a prescribed signature. */
@@ -431,7 +568,8 @@
     
     /** Validates a method against a prescribed signature. */
     protected void checkMethod(int mods, String result, String name,
-                               String[] params, String[] excepts) {
+                               String[] params, String[] excepts, 
+                               String value) {
         tested++;
         params = TypeHelper.qualifiedUserTypeNames(params);
         excepts = TypeHelper.qualifiedUserTypeNames(excepts);
@@ -463,7 +601,7 @@
             mods |= Modifier.PUBLIC;
             mods |= Modifier.ABSTRACT;
         }
-        if (mods != method.getModifiers()) {
+        if (mods != convertModifiers(method)) {
             handleMismatch(
                 "method declaration: non-matching modifiers;",
                 Formatter.toString(mods, result, name, params, excepts),
@@ -485,6 +623,27 @@
                 Formatter.toString(mods, result, name, params, excepts),
                 Formatter.toString(method));
         }
+        
+        // check default value of an annotation element (method)
+        if (value != null) {
+            Object actualValue = null;
+            try {
+                actualValue = method.getDefaultValue();
+            } catch (Exception ex) {
+                handleProblem("method declaration: cannot access default "
+                              + "value, exception: " + ex + ";",
+                              Formatter.toString(mods, result, name, value));
+            }
+            // check value expected versus actual
+            String wrong = checkValue(value, result, actualValue);
+
+            if (wrong != null) {
+                handleMismatch(
+                    "method declaration: non-matching default value;",
+                    Formatter.toString(mods, result, name + "() default ", wrong),
+                    Formatter.toString(method));
+            }
+        }
 
         // method OK
         members.remove(method);
@@ -521,7 +680,7 @@
         if (isInterface) {
             mods |= Modifier.ABSTRACT;
         }
-        if (mods != cls.getModifiers()) {
+        if (mods != convertModifiers(cls)) {
             handleMismatch(
                 "class declaration: non-matching modifiers;",
                 Formatter.toString(mods, name, ext, impl),
@@ -575,6 +734,54 @@
         }
     }
 
+    /** Return modifiers for the class, but handling enum and annotation
+     * as if they had a special modifier.
+     * @param cls the class
+     * @return modifiers of the class with extra flags for enum and annotation
+     */protected int convertModifiers(Class cls) {
+        int result = cls.getModifiers();
+        // first remove extraneous stuff
+        result &= ALL_MODIFIERS;
+        // if enum, set pseudo enum flag
+        if (cls.isEnum())
+            result |= ENUM;
+        // if annotation, set pseudo annotation flag
+        if (cls.isAnnotation()) 
+            result |= ANNOTATION;
+        return result;
+    }
+
+    /** Return modifiers for the method, but handling enum and annotation
+     * as if they had a special modifier.
+     * @param method the method
+     * @return modifiers of the class with extra flags for enum and annotation
+     */protected int convertModifiers(Method method) {
+        int result = method.getModifiers();
+        // first remove extraneous stuff
+        result &= ALL_MODIFIERS;
+        // if enum, set pseudo enum flag
+        if (method.getReturnType().isEnum())
+            result |= ENUM;
+        // if annotation, set pseudo annotation flag
+        if (method.getReturnType().isAnnotation()) 
+            result |= ANNOTATION;
+        return result;
+    }
+
+    /** Return modifiers for the field, but handling enum
+     * as if it had a special modifier.
+     * @param field the field
+     * @return modifiers of the class with extra flag for enum
+     */protected int convertModifiers(Field field) {
+        int result = field.getModifiers();
+        // first remove extraneous stuff
+        result &= ALL_MODIFIERS;
+        // if enum, set pseudo enum flag
+        if (field.isEnumConstant())
+            result |= ENUM;
+        return result;
+    }
+
     // ----------------------------------------------------------------------
     // Parser for Signature Descriptor Files
     // ----------------------------------------------------------------------
@@ -808,6 +1015,42 @@
         }
     
         /**
+         * Scans for an array literal. 
+         * Limitation: only the empty array "{}" can be scanned.
+         * @return <code>null</code> if the next token is not an array
+         */
+        protected String scanArrayLiteral()
+            throws IOException, ParseException {
+            // parse stored token if any
+            String t;
+            if ((t = getLookAhead()) != null) {
+                if (t.charAt(0) != '{' || t.charAt(1) != '}') {
+                    setLookAhead(t); // not a string literal
+                    return null;
+                }
+                return t;
+            }
+
+            // parse first char
+            if (!skip()) {
+                throw new ParseException(msgUnexpectedEOF(), 0);
+            }
+            ir.mark(1);
+            char c = (char)ir.read();
+            if (c != '{') {
+                ir.reset(); // not start of a string literal
+                return null;
+            }
+            c = (char)ir.read();
+            if (c != '}') {
+                ir.reset(); // not end of a string literal
+                return null;
+            }
+        
+            return "{}";
+        }
+    
+        /**
          * Returns the next token to be parsed.
          * @return never <code>null</code>
          */
@@ -854,6 +1097,7 @@
             if ((t = scanNumberLiteral()) != null) {
             } else if ((t = scanStringLiteral()) != null) {
             } else if ((t = scanCharacterLiteral()) != null) {
+            } else if ((t = scanArrayLiteral()) != null) {
             }
             //log.println("parseLiteral() : '" + t + "'");
             return t;
@@ -873,6 +1117,24 @@
         }
     
         /**
+         * Parses the next token and validates that it is a constant,
+         * which is either a literal or a static member.
+         * @return the description of the field
+         */
+        protected String demandConstant()
+            throws IOException, ParseException {
+            final String literal = parseLiteral();
+            if (literal != null) {
+                return literal;
+            }
+            final String field = demandIdentifier();
+            if (field == null) {
+                throw new ParseException(msgUnexpectedToken(parseToken()), 0);
+            }
+            return field;
+        }
+    
+        /**
          * Parses any available Java modifiers.
          * @return an int value with the parsed modifiers' bit set
          */
@@ -883,8 +1145,9 @@
                 // parse known modifiers
                 final String t = parseToken();
                 if      (t.equals("abstract")) m |= Modifier.ABSTRACT;
-                else if (t.equals("annotation")) m |= (0x2000 + Modifier.ABSTRACT + Modifier.INTERFACE);
-                else if (t.equals("enum")) m |= 0x4000 + Modifier.FINAL;
+                else if (t.equals("annotation")) m |= 
+                        (ANNOTATION + Modifier.ABSTRACT + Modifier.INTERFACE);
+                else if (t.equals("enum")) m |= ENUM;
                 else if (t.equals("final")) m |= Modifier.FINAL;
                 else if (t.equals("interface")) m |= Modifier.INTERFACE;
                 else if (t.equals("native")) m |= Modifier.NATIVE;
@@ -1033,7 +1296,7 @@
                 return null; // no member to parse
             }
             final String memberName = parseIdentifier(); // null if constructor
-
+            
             // parse optional field value or parameter+exception list
             final String value;
             final String[] params;
@@ -1058,12 +1321,17 @@
                     if (tt.equals("throws")) {
                         excepts = demandIdentifierList();
                         demandToken(";");
+                        value = null;
                     } else if (tt.equals(";")) {
                         excepts = new String[]{};
+                        value = null;
+                    } else if (tt.equals("default")) {
+                        value = demandConstant();
+                        demandToken(";");
+                        excepts = new String[]{};
                     } else {
                         throw new ParseException(msgUnexpectedToken(tt), 0);
                     }
-                    value = null;
                 } else {
                     throw new ParseException(msgUnexpectedToken(tvp), 0);
                 }
@@ -1078,7 +1346,7 @@
                     name = typeOrName;
                     checkConstructor(mods, params, excepts);
                 } else {
-                    checkMethod(mods, typeOrName, memberName, params, excepts);
+                    checkMethod(mods, typeOrName, memberName, params, excepts, value);
                 }
             }
 
@@ -1091,6 +1359,7 @@
          * to a handler.
          * @return <code>null</code> if there's no class definition
          */
+        @SuppressWarnings("empty-statement")
         protected String parseClass()
             throws IOException, ParseException {
             // parse optional modifiers, class token, and class name
@@ -1130,7 +1399,7 @@
             // verify class header
             checkClass(mods, name, ext, impl);
 
-            // process members
+            // process members; empty-statement intentional
             while (parseMember() != null);
             demandToken("}");
 
@@ -1146,6 +1415,7 @@
          * the class definitions.
          * @param descrFileNames list of signature descriptor file names
          */
+        @SuppressWarnings("empty-statement")
         public void parse(List descrFileNames)
             throws IOException, ParseException {        
             for (Iterator i = descrFileNames.iterator(); i.hasNext();) {
@@ -1157,6 +1427,7 @@
                     ir = new LineNumberReader(new FileReader(descriptorFile));
                     ir.setLineNumber(1);
                     setLookAhead(null);
+                    // empty-statement intentional
                     while (parseClass() != null);
                 } finally {
                     descriptorFile = null;



Mime
View raw message