You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/06/17 11:33:11 UTC

svn commit: r668586 - in /myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb: EmptyAnnotationVisitor.java EmptyClassVisitor.java

Author: skitching
Date: Tue Jun 17 02:33:11 2008
New Revision: 668586

URL: http://svn.apache.org/viewvc?rev=668586&view=rev
Log:
Fix exception that occurred when AsmHelper processed a class with annotations.

Added:
    myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyAnnotationVisitor.java   (with props)
Modified:
    myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyClassVisitor.java

Added: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyAnnotationVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyAnnotationVisitor.java?rev=668586&view=auto
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyAnnotationVisitor.java (added)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyAnnotationVisitor.java Tue Jun 17 02:33:11 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.orchestra.dynaForm.metadata.impl.ejb;
+
+import org.objectweb.asm.AnnotationVisitor;
+
+/**
+ * An empty implementation of the ASM AnnotationVisitor interface.
+ * <p>
+ * This class is completely stateless, and does absolutely nothing
+ * (except keep ASM happy).
+ */
+public class EmptyAnnotationVisitor implements AnnotationVisitor
+{
+    public void visit(String name, Object value)
+    {
+    }
+
+    public void visitEnd()
+    {
+    }
+
+    public void visitEnum(String name, String desc, String value)
+    {
+    }
+
+    public AnnotationVisitor visitAnnotation(String name, String desc)
+    {
+        return this;
+    }
+
+    public AnnotationVisitor visitArray(String name)
+    {
+        return this;
+    }
+}

Propchange: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyAnnotationVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyClassVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyClassVisitor.java?rev=668586&r1=668585&r2=668586&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyClassVisitor.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EmptyClassVisitor.java Tue Jun 17 02:33:11 2008
@@ -29,6 +29,8 @@
  */
 public class EmptyClassVisitor implements ClassVisitor
 {
+    private static final AnnotationVisitor ANNOTATION_VISITOR = new EmptyAnnotationVisitor();
+
     public void visitOuterClass(final String owner, final String name, final String desc)
     {
     }
@@ -63,7 +65,11 @@
 
     public AnnotationVisitor visitAnnotation(final String desc, final boolean visible)
     {
-        return null;
+        // Aargh. Methods visitMethod and visitField are permitted to return null, indicating
+        // that they do not want to visit the related data. But this method is not permitted
+        // to return null; an exception will occur when visiting any annotated class if null
+        // is returned. So instead return a stateless object that does nothing.
+        return ANNOTATION_VISITOR;
     }
 
     public MethodVisitor visitMethod(final int access, final String name, final String desc,