JSR_308 - Fix for target location and catch variable attribute
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index b58ba98..b57d097 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -1937,7 +1937,7 @@
LocalVariableBinding localVariable = this.codeStream.locals[i];
LocalDeclaration declaration = localVariable.declaration;
if (declaration == null
- || declaration.isArgument()
+ || (declaration.isArgument() && ((declaration.bits & ASTNode.CatchVariable) == 0))
|| (localVariable.initializationCount == 0)
|| ((declaration.bits & ASTNode.HasTypeAnnotations) == 0)) {
continue;
@@ -4114,6 +4114,7 @@
}
private void generateTypeAnnotation(AnnotationContext annotationContext, int currentOffset) {
+ int targetType = annotationContext.targetType;
if (annotationContext.wildcard != null) {
generateWilcardTypeAnnotation(annotationContext, currentOffset);
return;
@@ -4129,7 +4130,6 @@
annotationContext.primaryAnnotations,
annotationContext.annotation,
annotationContext.annotationsOnDimensions);
- int targetType = annotationContext.targetType;
if (locations != null) {
// convert to GENERIC_OR_ARRAY type
switch(targetType) {
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index bc46ff2..d64997a 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -248,6 +248,9 @@
// for all declarations that can contain type references that have type annotations
public static final int HasTypeAnnotations = Bit30;
+ // tag catch block variable as catch variable to distinguish them from argument
+ public static final int CatchVariable = Bit1;
+
public ASTNode() {
super();
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index ed39d39..0c23a3f 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -761,14 +761,8 @@
long metaTagBits = annotationType.getAnnotationTagBits(); // could be forward reference
if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) {
- // does not specify any target restriction - type parameter and type use target are never implicit
- switch (this.recipient.kind()) {
- case Binding.TYPE_PARAMETER :
- case Binding.TYPE_USE :
- break;
- default:
- break checkTargetCompatibility;
- }
+ // does not specify any target restriction - all locations are possible including type annotations
+ break checkTargetCompatibility;
}
switch (this.recipient.kind()) {
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
index 1404c76..2bafb12 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -138,7 +138,9 @@
}
// catch var is always set
- LocalVariableBinding catchArg = this.catchArguments[i].binding;
+ Argument catchVariable = this.catchArguments[i];
+ catchVariable.bits |= ASTNode.CatchVariable;
+ LocalVariableBinding catchArg = catchVariable.binding;
catchInfo.markAsDefinitelyAssigned(catchArg);
catchInfo.markAsDefinitelyNonNull(catchArg);
/*
diff --git a/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index e03ed21..c1a3f47 100644
--- a/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
@@ -194,6 +194,42 @@
this.currentWildcard = wildcard;
return true;
}
+ public boolean visit(Argument argument, BlockScope scope) {
+ if ((argument.bits & ASTNode.CatchVariable) == 0) {
+ return true;
+ }
+ for (int i = 0, max = this.localVariable.initializationCount; i < max; i++) {
+ int startPC = this.localVariable.initializationPCs[i << 1];
+ int endPC = this.localVariable.initializationPCs[(i << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ return true;
+ }
+ }
+ return false;
+ }
+ public boolean visit(Argument argument, ClassScope scope) {
+ if ((argument.bits & ASTNode.CatchVariable) == 0) {
+ return true;
+ }
+ for (int i = 0, max = this.localVariable.initializationCount; i < max; i++) {
+ int startPC = this.localVariable.initializationPCs[i << 1];
+ int endPC = this.localVariable.initializationPCs[(i << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ return true;
+ }
+ }
+ return false;
+ }
+ public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
+ for (int i = 0, max = this.localVariable.initializationCount; i < max; i++) {
+ int startPC = this.localVariable.initializationPCs[i << 1];
+ int endPC = this.localVariable.initializationPCs[(i << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ return true;
+ }
+ }
+ return false;
+ }
public void endVisit(Wildcard wildcard, BlockScope scope) {
this.currentWildcard = null;
}