Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 226328 Details for
Bug 399453
[1.8][compiler] Annotation preceding the first dimension in array creation expression is added to the type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed fix
Fix-for-bug-399453.patch (text/plain), 7.32 KB, created by
Jay Arthanareeswaran
on 2013-01-30 11:38:55 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2013-01-30 11:38:55 EST
Size:
7.32 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java >index 663eeb9..8f8256c 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2012 IBM Corporation and others. >+ * Copyright (c) 2009, 2013 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 >@@ -3790,4 +3790,48 @@ > "}\n"; > checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString); > } >+public void test0138() throws IOException { >+ String source = >+ "import java.lang.annotation.Target;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [bar()] @Marker @Marker2 [];\n" + >+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [X.bar2(2)] @Marker @Marker2 [];\n" + >+ " }\n" + >+ " public int bar() {\n" + >+ " return 2;\n" + >+ " }\n" + >+ " public static int bar2(int k) {\n" + >+ " return k;\n" + >+ " }\n" + >+ "}\n" + >+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" + >+ "@interface Marker {}\n" + >+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" + >+ "@interface Marker2 {}\n"; >+ String expectedUnitToString = >+ "import java.lang.annotation.Target;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "public class X {\n" + >+ " public X() {\n" + >+ " super();\n" + >+ " }\n" + >+ " public void foo() {\n" + >+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [bar()] @Marker @Marker2 [];\n" + >+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [X.bar2(2)] @Marker @Marker2 [];\n" + >+ " }\n" + >+ " public int bar() {\n" + >+ " return 2;\n" + >+ " }\n" + >+ " public static int bar2(int k) {\n" + >+ " return k;\n" + >+ " }\n" + >+ "}\n" + >+ "@Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {\n" + >+ "}\n" + >+ "@Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker2 {\n" + >+ "}\n"; >+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString); >+} > } >diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java >index ec92038..81f042f 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java >@@ -3117,4 +3117,40 @@ > "The annotation @Marker2 is disallowed for this location\n" + > "----------\n"); > } >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=399453 >+ public void testBug399453() { >+ this.runNegativeTest( >+ new String[]{ >+ "X.java", >+ "import java.lang.annotation.Target;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [@Marker bar()] @Marker @Marker2 [];\n" + >+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [@Marker X.bar2(2)] @Marker @Marker2 [];\n" + >+ " }\n" + >+ " public int bar() {\n" + >+ " return 2;\n" + >+ " }\n" + >+ " public static int bar2(int k) {\n" + >+ " return k;\n" + >+ " }\n" + >+ "}\n" + >+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" + >+ "@interface Marker {}\n" + >+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" + >+ "@interface Marker2 {}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [@Marker bar()] @Marker @Marker2 [];\n" + >+ " ^^^^^^^\n" + >+ "Syntax error, type annotations are illegal here\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [@Marker X.bar2(2)] @Marker @Marker2 [];\n" + >+ " ^^^^^^^\n" + >+ "Syntax error, type annotations are illegal here\n" + >+ "----------\n"); >+ } > } >\ No newline at end of file >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >index 16e21bb..65516cf 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 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 >@@ -5126,22 +5126,25 @@ > this.identifierLengthPtr--; > } else { > this.identifierLengthStack[this.identifierLengthPtr]--; >- int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]; >- Annotation [] typeAnnotations; >- if (length != 0) { >- System.arraycopy( >- this.typeAnnotationStack, >- (this.typeAnnotationPtr -= length) + 1, >- typeAnnotations = new Annotation[length], >- 0, >- length); >- problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]); >- } > m.receiver = getUnspecifiedReference(); > m.sourceStart = m.receiver.sourceStart; > } >+ rejectTypeAnnotationsOnMethodInvocation(); > pushOnExpressionStack(m); > } >+private void rejectTypeAnnotationsOnMethodInvocation() { >+ int length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]; >+ Annotation [] typeAnnotations; >+ if (length != 0) { >+ System.arraycopy( >+ this.typeAnnotationStack, >+ (this.typeAnnotationPtr -= length) + 1, >+ typeAnnotations = new Annotation[length], >+ 0, >+ length); >+ problemReporter().misplacedTypeAnnotations(typeAnnotations[0], typeAnnotations[typeAnnotations.length - 1]); >+ } >+} > protected void consumeMethodInvocationNameWithTypeArguments() { > // MethodInvocation ::= Name '.' TypeArguments 'Identifier' '(' ArgumentListopt ')' >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 399453
: 226328