1.5 - 63590
diff --git a/buildnotes_jdt-core.html b/buildnotes_jdt-core.html
index 943d683..5457699 100644
--- a/buildnotes_jdt-core.html
+++ b/buildnotes_jdt-core.html
@@ -93,7 +93,9 @@
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=63555">63555</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=63590">63590</a>
+[1.5] Cheetah allows generic throws clause
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=63555">63555</a>
[1.5] Cannot put generic type fields inside static inner class
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=58722">58722</a>
[1.5] cannot extend interfaces
diff --git a/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index 3b511ef..b130dbb 100644
--- a/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -903,6 +903,8 @@
int IncorrectArityForParameterizedConstructor = TypeRelated + 554;
/** @since 3.1 */
int ParameterizedConstructorArgumentTypeMismatch = TypeRelated + 555;
+ /** @since 3.1 */
+ int InvalidParameterizedExceptionType = TypeRelated + 556;
/**
* Foreach
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java b/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
index 1427d19..cff9f6d 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
@@ -88,10 +88,18 @@
// provide the scope with a side effect : insertion of a LOCAL
// that represents the argument. The type must be from JavaThrowable
- TypeBinding tb = type.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
- if (tb == null)
+ TypeBinding exceptionType = this.type.resolveType(scope);
+ if (exceptionType == null) return null;
+ if (exceptionType.isGenericType() || exceptionType.isParameterizedType()) {
+ scope.problemReporter().invalidParameterizedExceptionType(exceptionType, this);
return null;
-
+ }
+ TypeBinding throwable = scope.getJavaLangThrowable();
+ if (!exceptionType.isCompatibleWith(throwable)) {
+ scope.problemReporter().typeMismatchError(exceptionType, throwable, this);
+ return null;
+ }
+
Binding existingVariable = scope.getBinding(name, BindingIds.VARIABLE, this, false /*do not resolve hidden field*/);
if (existingVariable != null && existingVariable.isValidBinding()){
if (existingVariable instanceof LocalVariableBinding && this.hiddenVariableDepth == 0) {
@@ -101,10 +109,10 @@
scope.problemReporter().localVariableHiding(this, existingVariable, false);
}
- binding = new LocalVariableBinding(this, tb, modifiers, false); // argument decl, but local var (where isArgument = false)
+ binding = new LocalVariableBinding(this, exceptionType, modifiers, false); // argument decl, but local var (where isArgument = false)
scope.addLocalVariable(binding);
binding.constant = NotAConstant;
- return tb;
+ return exceptionType;
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
index e822b65..fe9c6c2 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
@@ -516,17 +516,21 @@
if (this.catchBlocks != null) {
int length = this.catchArguments.length;
TypeBinding[] argumentTypes = new TypeBinding[length];
+ boolean catchHasError = false;
for (int i = 0; i < length; i++) {
BlockScope catchScope = new BlockScope(scope);
if (finallyScope != null){
finallyScope.shiftScopes[i+1] = catchScope;
}
// side effect on catchScope in resolveForCatch(..)
- if ((argumentTypes[i] = catchArguments[i].resolveForCatch(catchScope)) == null)
- return;
+ if ((argumentTypes[i] = catchArguments[i].resolveForCatch(catchScope)) == null) {
+ catchHasError = true;
+ }
catchBlocks[i].resolveUsing(catchScope);
}
-
+ if (catchHasError) {
+ return;
+ }
// Verify that the catch clause are ordered in the right way:
// more specialized first.
this.caughtExceptionTypes = new ReferenceBinding[length];
diff --git a/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index de6894e..1dccc14 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -814,6 +814,10 @@
if (resolvedExceptionType == null) {
continue;
}
+ if (resolvedExceptionType.isGenericType() || resolvedExceptionType.isParameterizedType()) {
+ methodDecl.scope.problemReporter().invalidParameterizedExceptionType(resolvedExceptionType, exceptionTypes[i]);
+ continue;
+ }
if (throwable != resolvedExceptionType && !throwable.isSuperclassOf(resolvedExceptionType)) {
methodDecl.scope.problemReporter().cannotThrowType(this, methodDecl, exceptionTypes[i], resolvedExceptionType);
continue;
diff --git a/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index cda84e7..32ebac2 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -1843,6 +1843,14 @@
expression.sourceStart,
expression.sourceEnd);
}
+public void invalidParameterizedExceptionType(TypeBinding exceptionType, ASTNode location) {
+ this.handle(
+ IProblem.InvalidParameterizedExceptionType,
+ new String[] {new String(exceptionType.readableName())},
+ new String[] {new String(exceptionType.shortReadableName())},
+ location.sourceStart,
+ location.sourceEnd);
+}
public void invalidExpressionAsStatement(Expression expression){
this.handle(
IProblem.InvalidExpressionAsStatement,
diff --git a/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index f10a4ff..7212ef9 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -424,6 +424,7 @@
553 = The constructor {0}({1}) of type {2} is not generic; it cannot be parameterized with arguments <{3}>
554 = Incorrect number of type arguments for generic constructor <{3}>{0}({1}) of type {2}; it cannot be parameterized with arguments <{4}>
555 = The parameterized constructor <{3}>{0}({1}) of type {2} is not applicable for the arguments ({4})
+556 = Cannot use the parameterized type {0} either in catch block or throws clause
### FOREACH
580 = Type mismatch: cannot convert from element type {0} to {1}