myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r940408 - in /myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core: ClassScanVisitor.java MethodScanVisitor.java
Date Mon, 03 May 2010 10:17:15 GMT
Author: werpu
Date: Mon May  3 10:17:14 2010
New Revision: 940408

URL: http://svn.apache.org/viewvc?rev=940408&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-127

fixed, added null checks in front of every type conversion just to make sure
that the code does not trigger an npe
(better to have a lost dependency than an npe)

Modified:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java?rev=940408&r1=940407&r2=940408&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/ClassScanVisitor.java
Mon May  3 10:17:14 2010
@@ -56,12 +56,15 @@ public class ClassScanVisitor implements
     public void visit(int version, int access, String name,
                       String signature, String superName, String[] interfaces) {
         _currentlyVistedClass = Type.getObjectType(name).getClassName();
-        registerDependency(Type.getObjectType(superName));
+        if (superName != null)
+            registerDependency(Type.getObjectType(superName));
+
         handleGenerics(signature, true);
 
         if (interfaces != null && interfaces.length > 0) {
             for (String currInterface : interfaces) {
-                registerDependency(Type.getObjectType(currInterface));
+                if (currInterface != null)
+                    registerDependency(Type.getObjectType(currInterface));
             }
         }
     }
@@ -73,33 +76,33 @@ public class ClassScanVisitor implements
     public void visitOuterClass(String owner, String name, String description) {
         //nothing has to be done here I guess because
         //we only try to fetch the dependencies
-        _log.log(Level.FINEST, "visitOuterClass: {0} {1} {2}", new String [] {owner, name,
description});
+        _log.log(Level.FINEST, "visitOuterClass: {0} {1} {2}", new String[]{owner, name,
description});
 
     }
 
     public AnnotationVisitor visitAnnotation(String description,
                                              boolean visible) {
-        registerDependency(Type.getType(description));
+        if (description != null)
+            registerDependency(Type.getType(description));
 
         return null;
     }
 
     public void visitAttribute(Attribute attribute) {
-        //_log._log(Level.INFO, "Attribute: {0}", attribute.type);
-        System.out.println(attribute.getClass().getName());
     }
 
     public void visitInnerClass(String name, String outerName,
                                 String innerName, int access) {
         //same as outer class
-        _log.log(Level.FINEST, "visitInnerClass: {0}  {1} {2} ", new String [] {name, outerName,
innerName});
+        _log.log(Level.FINEST, "visitInnerClass: {0}  {1} {2} ", new String[]{name, outerName,
innerName});
     }
 
     public FieldVisitor visitField(int access, String name, String description,
                                    String signature, Object value) {
         //_log._log(Level.INFO, "Field:{0} {1} ", new Object[]{description, name});
         handleGenerics(signature, false);
-        registerDependency(Type.getType(description));
+        if (description != null)
+            registerDependency(Type.getType(description));
 
         return null;
     }
@@ -119,23 +122,26 @@ public class ClassScanVisitor implements
     public MethodVisitor visitMethod(int access, String name,
                                      String description, String signature, String[] exceptions)
{
 
-        registerDependency(Type.getReturnType(description));
+        if (description != null)
+            registerDependency(Type.getReturnType(description));
 
         handleGenerics(signature, true);
 
-        for (Type argumentType : Type.getArgumentTypes(description)) {
-            registerDependency(argumentType);
+        if (description != null) {
+            for (Type argumentType : Type.getArgumentTypes(description)) {
+                registerDependency(argumentType);
+            }
         }
         return new MethodScanVisitor(_engineType, _rootClass, _currentlyVistedClass, _dependencyRegistry);
     }
 
     private void handleGenerics(String signature, boolean accept) {
-        if(signature != null && signature.contains("<")) {
+        if (signature != null && signature.contains("<")) {
             SignatureReader reader = new SignatureReader(signature);
-            if(accept)
-                reader.accept(new DependencySignatureVisitor(_dependencyRegistry,_engineType,
_rootClass, _currentlyVistedClass));
+            if (accept)
+                reader.accept(new DependencySignatureVisitor(_dependencyRegistry, _engineType,
_rootClass, _currentlyVistedClass));
             else
-                reader.acceptType(new DependencySignatureVisitor(_dependencyRegistry,_engineType,
_rootClass, _currentlyVistedClass));
+                reader.acceptType(new DependencySignatureVisitor(_dependencyRegistry, _engineType,
_rootClass, _currentlyVistedClass));
         }
     }
 

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java?rev=940408&r1=940407&r2=940408&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/core/dependencyScan/core/MethodScanVisitor.java
Mon May  3 10:17:14 2010
@@ -58,14 +58,16 @@ class MethodScanVisitor implements Metho
     }
 
     public AnnotationVisitor visitAnnotation(String description, boolean b) {
-        registerDependency(Type.getType(description));
-
+        if(description != null) {
+            registerDependency(Type.getType(description));
+        }
         return null;
     }
 
     public AnnotationVisitor visitParameterAnnotation(int opCode, String description, boolean
b) {
-        registerDependency(Type.getType(description));
-
+        if(description != null) {
+            registerDependency(Type.getType(description));
+        }
         return null;
     }
 
@@ -96,10 +98,11 @@ class MethodScanVisitor implements Metho
     public void visitTypeInsn(int opCode, String castType) {
         //cast
         // log.log(Level.INFO, "TypeInsn: {0} ", new String[]{castType});
-        registerDependency(Type.getObjectType(castType));
-        if (_log.isLoggable(Level.FINEST))
-            _log.log(Level.FINEST, "visitTypeInsn {0}", castType);
-
+        if (castType != null) {
+            registerDependency(Type.getObjectType(castType));
+            if (_log.isLoggable(Level.FINEST))
+                _log.log(Level.FINEST, "visitTypeInsn {0}", castType);
+        }
     }
 
     private void registerDependency(Type dependency) {
@@ -194,14 +197,19 @@ class MethodScanVisitor implements Metho
     public void visitTryCatchBlock(Label label, Label label1, Label label2, String catchType)
{
         //try catch block type information in the last string
         //log.log(Level.INFO, "visitTryCatchBlock: {0} {1} {2} {3}", new Object[]{label.toString(),
label1.toString(), label2.toString(), catchType});
-        registerDependency(Type.getObjectType(catchType));
-
+        if (catchType != null) {
+            registerDependency(Type.getObjectType(catchType));
+        }
     }
 
     public void visitLocalVariable(String name, String description, String signature, Label
label, Label label1, int i) {
         //local variable on method level
-        registerDependency(Type.getType(description));
-        handleGenerics(signature);
+        if (description != null) {
+            registerDependency(Type.getType(description));
+        }
+        if (signature != null) {
+            handleGenerics(signature);
+        }
     }
 
     public void visitLineNumber(int i, Label label) {



Mime
View raw message