changeset 505:0a305235fa31

replace asserts with throw AssertionError remove some commented lines
author mali
date Mon, 27 Apr 2009 16:43:30 -0400
parents 261c5e6b8392
children b0346cc234aa
files src/share/classes/com/sun/source/util/AbstractTypeProcessor.java src/share/classes/com/sun/tools/classfile/ClassWriter.java src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java src/share/classes/com/sun/tools/javac/code/TargetType.java src/share/classes/com/sun/tools/javac/comp/Check.java src/share/classes/com/sun/tools/javac/comp/TransTypes.java src/share/classes/com/sun/tools/javac/jvm/ClassReader.java src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java src/share/classes/com/sun/tools/javac/tree/JCTree.java
diffstat 9 files changed, 23 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java	Mon Apr 27 16:43:30 2009 -0400
@@ -177,9 +177,6 @@
 
         @Override
         public void finished(TaskEvent e) {
-            assert e.getTypeElement() != null;
-            assert e.getCompilationUnit() != null;
-
             Log log = Log.instance(env.getContext());
 
             if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
@@ -187,8 +184,15 @@
                 hasInvokedTypeProcessingOver = true;
             }
 
-            if (e.getKind() != TaskEvent.Kind.ANALYZE
-                || !elements.remove(e.getTypeElement().getQualifiedName()))
+            if (e.getKind() != TaskEvent.Kind.ANALYZE)
+                return;
+
+            if (e.getTypeElement() == null)
+                throw new AssertionError("event task without a type element");
+            if (e.getCompilationUnit() == null)
+                throw new AssertionError("even task without compilation unit");
+
+            if (!elements.remove(e.getTypeElement().getQualifiedName()))
                 return;
 
             if (log.nerrors != 0)
--- a/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Mon Apr 27 16:43:30 2009 -0400
@@ -787,7 +787,7 @@
             case UNKNOWN:
                 break;
             default:
-//                throw new AssertionError("unknown type: " + p);
+                throw new AssertionError("unknown type: " + p);
             }
 
             // Append location data for generics/arrays.
--- a/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java	Mon Apr 27 16:43:30 2009 -0400
@@ -149,7 +149,6 @@
         case UNKNOWN:
             break;
         default:
-//            throw new AssertionError("unknown type: " + position);
         }
 
         if (type.hasLocation()) {
@@ -239,7 +238,6 @@
         case UNKNOWN:
             break;
         default:
-//            throw new AssertionError("unknown type: " + pos);
         }
 
         if (pos.type.hasLocation()) {
@@ -378,7 +376,7 @@
             case UNKNOWN:
                 break;
             default:
-//                throw new AssertionError("unknown type: " + type);
+                throw new AssertionError("unknown type: " + type);
             }
 
             // Append location data for generics/arrays.
@@ -516,8 +514,9 @@
         private Set<TargetAttribute> flags;
 
         TargetType(int targetTypeValue, TargetAttribute... attrs) {
-            assert targetTypeValue >= Byte.MIN_VALUE;
-            assert targetTypeValue <= Byte.MAX_VALUE;
+            if (targetTypeValue < Byte.MIN_VALUE
+                || targetTypeValue > Byte.MAX_VALUE)
+                throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
             this.targetTypeValue = (byte)targetTypeValue;
             this.flags = EnumSet.noneOf(TargetAttribute.class);
             for (TargetAttribute attr : attrs)
--- a/src/share/classes/com/sun/tools/javac/code/TargetType.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/code/TargetType.java	Mon Apr 27 16:43:30 2009 -0400
@@ -167,16 +167,10 @@
     private final int targetTypeValue;
     private Set<TargetAttribute> flags;
 
-    TargetType(int targetTypeValue, Set<TargetAttribute> flags) {
-        assert targetTypeValue >= Byte.MIN_VALUE;
-        assert targetTypeValue <= Byte.MAX_VALUE;
-        this.targetTypeValue = (byte)targetTypeValue;
-        this.flags = flags;
-    }
-
     TargetType(int targetTypeValue, TargetAttribute... attributes) {
-        assert targetTypeValue >= Byte.MIN_VALUE;
-        assert targetTypeValue <= Byte.MAX_VALUE;
+        if (targetTypeValue < Byte.MIN_VALUE
+                || targetTypeValue > Byte.MAX_VALUE)
+                throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
         this.targetTypeValue = (byte)targetTypeValue;
         flags = EnumSet.noneOf(TargetAttribute.class);
         for (TargetAttribute attr : attributes)
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Apr 27 16:43:30 2009 -0400
@@ -1809,7 +1809,8 @@
     }
 
     public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
-        assert a.type != null;
+        if (a.type == null)
+            throw new AssertionError("annotation tree hasn't been attributed yet: " + a);
         validateAnnotation(a);
 
         if (!isTypeAnnotation(a, isTypeParameter))
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Apr 27 16:43:30 2009 -0400
@@ -906,8 +906,6 @@
                 }
 
                 case TYPE_PARAMETER:
-//                    System.out.print("type parameter: " +
-//                            ((JCTypeParameter)frame).bounds.indexOf(tree) + " ");
                     if (path.tail.tail.head.getTag() == JCTree.CLASSDEF) {
                         JCClassDecl clazz = (JCClassDecl)path.tail.tail.head;
                         p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND;
@@ -947,7 +945,8 @@
 
                 case METHOD_INVOCATION: {
                     JCMethodInvocation invocation = (JCMethodInvocation)frame;
-                    assert invocation.typeargs.contains(tree);
+                    if (!invocation.typeargs.contains(tree))
+                        throw new AssertionError("{" + tree + "} is not an argument in the invocation: " + invocation);
                     p.type = TargetType.METHOD_TYPE_ARGUMENT;
                     p.pos = invocation.pos;
                     p.type_index = invocation.typeargs.indexOf(tree);
@@ -1038,7 +1037,6 @@
         }
 
         private int methodParamIndex(List<JCTree> path, JCTree param) {
-//            assert param.sym.getKind() == ElementKind.PARAMETER;
             List<JCTree> curr = path;
             if (curr.head != param)
                 curr = path.tail;
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Apr 27 16:43:30 2009 -0400
@@ -1438,7 +1438,7 @@
         case UNKNOWN:
             break;
         default:
-//            throw new AssertionError("unknown type: " + position);
+            throw new AssertionError("unknown type: " + position);
         }
 
         if (type.hasLocation()) {
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Apr 27 16:43:30 2009 -0400
@@ -991,7 +991,7 @@
         case UNKNOWN:
             break;
         default:
-//            throw new AssertionError("unknown position: " + p);
+            throw new AssertionError("unknown position: " + p);
         }
 
         // Append location data for generics/arrays.
--- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Mon Apr 27 16:14:44 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Mon Apr 27 16:43:30 2009 -0400
@@ -2037,7 +2037,6 @@
         }
         @Override
         public int getTag() {
-//            return underlyingType.getTag(); //ANNOTATED_TYPE;
             return ANNOTATED_TYPE;
         }
     }