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 204708 Details for
Bug 353474
type converters should include more annotations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
test & fix
Bug_353474.patch (text/plain), 9.14 KB, created by
Stephan Herrmann
on 2011-10-06 15:00:59 EDT
(
hide
)
Description:
test & fix
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2011-10-06 15:00:59 EDT
Size:
9.14 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >index c6f70e8..2af2c81 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >@@ -7,7 +7,9 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann - Contribution for Bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding >+ * Stephan Herrmann - Contributions for >+ * Bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding >+ * Bug 353474 - type converters should include more annotations > *******************************************************************************/ > package org.eclipse.jdt.core.tests.dom; > >@@ -50,7 +52,7 @@ > static { > // TESTS_NUMBERS = new int[] { 353 }; > // TESTS_RANGE = new int[] { 325, -1 }; >-// TESTS_NAMES = new String[] {"test0204"}; >+// TESTS_NAMES = new String[] {"testBug353474"}; > } > public static Test suite() { > return buildModelTestSuite(ASTConverter15Test.class); >@@ -11348,5 +11350,100 @@ > rhsType = ((Assignment)((ExpressionStatement)((Statement) statements.get(1))).getExpression()).getRightHandSide().resolveTypeBinding(); > assertFalse("Assignement compatible", rhsType.isAssignmentCompatible(assignmentType)); > } >+ // Bug 353474 - type converters should include more annotations >+ public void testBug353474() throws CoreException { >+ >+ this.createFolder("/Converter15/src/testBug353474/annot"); >+ String contents = >+ "package testBug353474.annot;\n" + >+ "import static java.lang.annotation.ElementType.*;\n" + >+ "import java.lang.annotation.*;\n" + >+ "@Retention(RetentionPolicy.CLASS)\n" + >+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE})\n" + >+ "public @interface Nullable {\n" + >+ "}\n"; >+ getWorkingCopy("/Converter15/src/testBug353474/annot/Nullable.java", contents, true/*resolve*/); >+ >+ this.createFolder("/Converter15/src/testBug353474/p1"); >+ contents = >+ "package testBug353474.p1;\n" + >+ "import testBug353474.annot.*;\n" + >+ "public class C1 {\n" + >+ " public @Nullable String foo(@Nullable Object arg) {\n" + >+ " return \"\";\n" + >+ " }\n" + >+ "}\n"; >+ getWorkingCopy("/Converter15/src/testBug353474/p1/C1.java", contents, true/*resolve*/); >+ >+ this.workingCopy = getWorkingCopy("/Converter15/src/testBug353474/p1/C2.java", true/*resolve*/); >+ contents = >+ "package testBug353474.p1;\n" + >+ "public class C2 {\n" + >+ " public String bar(C1 c1) {\n" + >+ " return c1.foo(null);\n" + >+ " }\n" + >+ "}\n"; >+ ASTNode node = buildAST( >+ contents, >+ this.workingCopy, >+ true); >+ assertNotNull("No node", node); >+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); >+ CompilationUnit compilationUnit = (CompilationUnit) node; >+ TypeDeclaration c2 = (TypeDeclaration) compilationUnit.types().get(0); >+ MethodDeclaration bar = (MethodDeclaration) c2.bodyDeclarations().get(0); >+ ReturnStatement returnStat = (ReturnStatement) bar.getBody().statements().get(0); >+ MethodInvocation fooCall = (MethodInvocation) returnStat.getExpression(); >+ IMethodBinding resolvedFoo = fooCall.resolveMethodBinding(); >+ IAnnotationBinding[] parameterAnnotations0 = resolvedFoo.getParameterAnnotations(0); >+ assertNotNull("Parameter annotation should not be null", parameterAnnotations0); >+ assertEquals("Should have exactly one annotation", 1, parameterAnnotations0.length); >+ assertEquals("Unexpected annotation name", "Nullable", parameterAnnotations0[0].getName()); >+ >+ IAnnotationBinding[] returnAnnotations = resolvedFoo.getAnnotations(); >+ assertNotNull("Return annotation should not be null", returnAnnotations); >+ assertEquals("Should have exactly one return annotation", 1, returnAnnotations.length); >+ assertEquals("Unexpected annotation name", "Nullable", returnAnnotations[0].getName()); >+ deleteFolder("/Converter15/src/testBug353474"); >+ } >+ // Bug 353474 - type converters should include more annotations >+ // secondary type comes from binary >+ public void testBug353474a() throws CoreException { >+ String jarLocation = getWorkspacePath()+"Converter15/bins/bug353474.jar"; >+ IJavaProject jp = createJavaProject("Bug353464a", new String[]{"src"}, new String[]{"CONVERTER_JCL15_LIB", jarLocation}, "bin", "1.5"); >+ try { >+ this.workingCopy = getWorkingCopy("/Bug353464a/src/testBug353474/p1/C2.java", true/*resolve*/); >+ String contents = >+ "package testBug353474.p1;\n" + >+ "public class C2 {\n" + >+ " public String bar(C1a c1) {\n" + >+ " return c1.foo(null);\n" + >+ " }\n" + >+ "}\n"; >+ ASTNode node = buildAST( >+ contents, >+ this.workingCopy, >+ true); >+ assertNotNull("No node", node); >+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); >+ CompilationUnit compilationUnit = (CompilationUnit) node; >+ TypeDeclaration c2 = (TypeDeclaration) compilationUnit.types().get(0); >+ MethodDeclaration bar = (MethodDeclaration) c2.bodyDeclarations().get(0); >+ ReturnStatement returnStat = (ReturnStatement) bar.getBody().statements().get(0); >+ MethodInvocation fooCall = (MethodInvocation) returnStat.getExpression(); >+ IMethodBinding resolvedFoo = fooCall.resolveMethodBinding(); >+ IAnnotationBinding[] parameterAnnotations0 = resolvedFoo.getParameterAnnotations(0); >+ assertNotNull("Parameter annotation should not be null", parameterAnnotations0); >+ assertEquals("Should have exactly one annotation", 1, parameterAnnotations0.length); >+ assertEquals("Unexpected annotation name", "Nullable", parameterAnnotations0[0].getName()); >+ >+ IAnnotationBinding[] returnAnnotations = resolvedFoo.getAnnotations(); >+ assertNotNull("Return annotation should not be null", returnAnnotations); >+ assertEquals("Should have exactly one return annotation", 1, returnAnnotations.length); >+ assertEquals("Unexpected annotation name", "Nullable", returnAnnotations[0].getName()); >+ } finally { >+ deleteProject(jp); >+ } >+ } > > } >\ No newline at end of file >diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter15/bins/bug353474.jar b/org.eclipse.jdt.core.tests.model/workspace/Converter15/bins/bug353474.jar >new file mode 100644 >index 0000000..f24640e >--- /dev/null >+++ b/org.eclipse.jdt.core.tests.model/workspace/Converter15/bins/bug353474.jar >Binary files differ >diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java >index a5e4af3..ffae433 100644 >--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java >+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -7,7 +7,9 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann <stephan@cs.tu-berlin.de> - TypeConverters don't set enclosingType - https://bugs.eclipse.org/bugs/show_bug.cgi?id=320841 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for >+ * Bug 320841 - TypeConverters don't set enclosingType >+ * Bug 353474 - type converters should include more annotations > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.parser; > >@@ -28,6 +30,7 @@ > import org.eclipse.jdt.core.IAnnotation; > import org.eclipse.jdt.core.IImportDeclaration; > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.ILocalVariable; > import org.eclipse.jdt.core.ISourceRange; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.Signature; >@@ -373,6 +376,7 @@ > char[][] argumentNames = methodInfo.getArgumentNames(); > int argumentCount = argumentTypeSignatures == null ? 0 : argumentTypeSignatures.length; > if (argumentCount > 0) { >+ ILocalVariable[] parameters = methodHandle.getParameters(); > long position = ((long) start << 32) + end; > method.arguments = new Argument[argumentCount]; > for (int i = 0; i < argumentCount; i++) { >@@ -387,6 +391,11 @@ > typeReference, > ClassFileConstants.AccDefault); > // do not care whether was final or not >+ // convert 1.5 specific constructs only if compliance is 1.5 or above >+ if (this.has1_5Compliance) { >+ /* convert annotations */ >+ method.arguments[i].annotations = convertAnnotations(parameters[i]); >+ } > } > } >
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 353474
:
200637
| 204708