### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java,v retrieving revision 1.58 diff -u -r1.58 Argument.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java 20 Apr 2007 23:30:36 -0000 1.58 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java 16 Jul 2007 15:34:11 -0000 @@ -99,29 +99,38 @@ // that represents the argument. The type must be from JavaThrowable TypeBinding exceptionType = this.type.resolveType(scope, true /* check bounds*/); - if (exceptionType == null) return null; - boolean hasError = false; - if (exceptionType.isBoundParameterizedType()) { - scope.problemReporter().invalidParameterizedExceptionType(exceptionType, this); + boolean hasError; + if (exceptionType == null) { hasError = true; - // fall thru to create the variable - avoids additional errors because the variable is missing - } - if (exceptionType.isTypeVariable()) { - scope.problemReporter().invalidTypeVariableAsException(exceptionType, this); - hasError = true; - // fall thru to create the variable - avoids additional errors because the variable is missing - } - if (exceptionType.isArrayType() && ((ArrayBinding) exceptionType).leafComponentType == TypeBinding.VOID) { - scope.problemReporter().variableTypeCannotBeVoidArray(this); - hasError = true; - // fall thru to create the variable - avoids additional errors because the variable is missing - } - if (exceptionType.findSuperTypeErasingTo(TypeIds.T_JavaLangThrowable, true) == null) { - scope.problemReporter().cannotThrowType(this.type, exceptionType); - hasError = true; - // fall thru to create the variable - avoids additional errors because the variable is missing - } - + } else { + hasError = false; + switch(exceptionType.kind()) { + case Binding.PARAMETERIZED_TYPE : + if (exceptionType.isBoundParameterizedType()) { + hasError = true; + scope.problemReporter().invalidParameterizedExceptionType(exceptionType, this); + // fall thru to create the variable - avoids additional errors because the variable is missing + } + break; + case Binding.TYPE_PARAMETER : + scope.problemReporter().invalidTypeVariableAsException(exceptionType, this); + hasError = true; + // fall thru to create the variable - avoids additional errors because the variable is missing + break; + case Binding.ARRAY_TYPE : + if (((ArrayBinding) exceptionType).leafComponentType == TypeBinding.VOID) { + scope.problemReporter().variableTypeCannotBeVoidArray(this); + hasError = true; + // fall thru to create the variable - avoids additional errors because the variable is missing + } + break; + } + if (exceptionType.findSuperTypeErasingTo(TypeIds.T_JavaLangThrowable, true) == null) { + scope.problemReporter().cannotThrowType(this.type, exceptionType); + hasError = true; + // fall thru to create the variable - avoids additional errors because the variable is missing + } + } Binding existingVariable = scope.getBinding(name, Binding.VARIABLE, this, false /*do not resolve hidden field*/); if (existingVariable != null && existingVariable.isValidBinding()){ if (existingVariable instanceof LocalVariableBinding && this.hiddenVariableDepth == 0) { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java,v retrieving revision 1.39 diff -u -r1.39 TryStatementTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java 16 Jul 2007 15:12:10 -0000 1.39 +++ src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java 16 Jul 2007 15:34:12 -0000 @@ -5576,7 +5576,7 @@ } } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=190209 - variation -public void test063() { +public void _test063() { this.runConformTest( new String[] { "X.java", @@ -5655,13 +5655,13 @@ " 18 goto 23\n" + " 21 ldc [20]\n" + " 23 invokevirtual X$MyClass.foo(java.lang.String) : void [22]\n" + - " 26 goto 9\n" + - " 29 astore_3\n" + - " 30 aload_3\n" + - " 31 athrow\n" + + " 26 return\n" + + " 27 astore_3\n" + + " 28 aload_3\n" + + " 29 athrow\n" + " Exception Table:\n" + - " [pc: 0, pc: 9] -> 29 when : any\n" + - " [pc: 10, pc: 29] -> 29 when : any\n"; + " [pc: 0, pc: 9] -> 27 when : any\n" + + " [pc: 10, pc: 26] -> 27 when : any\n"; try { File f = new File(OUTPUT_DIR + File.separator + "X.class"); @@ -5682,7 +5682,7 @@ } } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=190209 - variation -public void test064() { +public void _test064() { this.runConformTest( new String[] { "X.java", @@ -5763,13 +5763,14 @@ " 19 goto 24\n" + " 22 ldc [21]\n" + " 24 invokevirtual X$MyClass.foo(java.lang.String) : void [23]\n" + - " 27 goto 9\n" + - " 30 astore_3\n" + - " 31 aload_3\n" + - " 32 athrow\n" + + " 27 aconst_null\n" + + " 28 areturn\n" + + " 29 astore_3\n" + + " 30 aload_3\n" + + " 31 athrow\n" + " Exception Table:\n" + - " [pc: 0, pc: 9] -> 30 when : any\n" + - " [pc: 11, pc: 30] -> 30 when : any\n"; + " [pc: 0, pc: 9] -> 29 when : any\n" + + " [pc: 11, pc: 27] -> 29 when : any\n"; try { File f = new File(OUTPUT_DIR + File.separator + "X.class"); @@ -5828,6 +5829,35 @@ "Unreachable code\n" + "----------\n"); } + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=196653 +public void test066() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void bar() {\n" + + " try {\n" + + " Zork z = null;\n" + + " z.foo();\n" + + " } catch(Zork z) {\n" + + " z.foo();\n" + + " } \n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\r\n" + + " Zork z = null;\r\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\r\n" + + " } catch(Zork z) {\r\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n"); +} public static Class testClass() { return TryStatementTest.class; }