Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGauthier JACQUES2014-08-21 08:06:19 +0000
committerJayaprakash Arthanareeswaran2014-08-21 17:57:33 +0000
commit65f5152e309a08bb91b2b35f96e93b2fa93bae4f (patch)
treef44c719b31e3ea5ea4bf46210e7c5b8297b8a9f0 /org.eclipse.jdt.compiler.apt.tests
parentda5d5f5dcaeaf009feb139b87f69fd7bf09595b3 (diff)
downloadeclipse.jdt.core-65f5152e309a08bb91b2b35f96e93b2fa93bae4f.tar.gz
eclipse.jdt.core-65f5152e309a08bb91b2b35f96e93b2fa93bae4f.tar.xz
eclipse.jdt.core-65f5152e309a08bb91b2b35f96e93b2fa93bae4f.zip
Fixed bug 423885 - JDT's implementation of JSR-199 reports wrong errors
with classes generated by APT Change-Id: I7be75aaa581610e35efc09204d1aeb21601fbf08 Signed-off-by: Gauthier JACQUES <gauthier.jacques@gmail.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jarbin173483 -> 173483 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/jsr199/F.java18
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java14
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java26
4 files changed, 57 insertions, 1 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
index 79b1cdb868..2524570f50 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/jsr199/F.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/jsr199/F.java
new file mode 100644
index 0000000000..430b14f0c5
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/jsr199/F.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package targets.jsr199;
+
+public class F {
+
+ private static void staticMethod(){
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
index c020a08cbf..3a8a0abb8f 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/BatchTestUtils.java
@@ -97,7 +97,19 @@ public class BatchTestUtils {
public static void compileTree(JavaCompiler compiler, List<String> options, File targetFolder) {
compileTree(compiler, options, targetFolder, false);
}
+
+ public static void compileTree(JavaCompiler compiler, List<String> options, File targetFolder,
+ DiagnosticListener<? super JavaFileObject> listener) {
+ compileTree(compiler, options, targetFolder, false, listener);
+ }
+
public static void compileTree(JavaCompiler compiler, List<String> options, File targetFolder, boolean useJLS8Processors) {
+ compileTree(compiler, options, targetFolder, useJLS8Processors, null);
+ }
+
+ public static void compileTree(JavaCompiler compiler, List<String> options,
+ File targetFolder, boolean useJLS8Processors,
+ DiagnosticListener<? super JavaFileObject> listener) {
StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
// create new list containing inputfile
@@ -113,7 +125,7 @@ public class BatchTestUtils {
options.add(_tmpGenFolderName);
addProcessorPaths(options, useJLS8Processors);
options.add("-XprintRounds");
- CompilationTask task = compiler.getTask(printWriter, manager, null, options, null, units);
+ CompilationTask task = compiler.getTask(printWriter, manager, listener, options, null, units);
Boolean result = task.call();
if (!result.booleanValue()) {
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java
index 71d41b973f..26df4c82bf 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/ModelTests.java
@@ -17,6 +17,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
@@ -127,6 +129,12 @@ public class ModelTests extends TestCase {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
internalTest(compiler, VISITORPROC);
}
+
+ public void testReportedProblemsWithDiagnosticListener() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ internalTest(compiler, ELEMENTPROC,
+ "The method staticMethod() from the type targets.jsr199.F is never used locally\n");
+ }
/**
* Test functionality by running a particular processor against the types in
@@ -147,6 +155,24 @@ public class ModelTests extends TestCase {
// if not, it will set it to an error value.
assertEquals("succeeded", System.getProperty(processorClass));
}
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private void internalTest(JavaCompiler compiler, String processorClass, String errors) throws IOException {
+ System.clearProperty(processorClass);
+ File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "jsr199");
+ BatchTestUtils.copyResources("targets/jsr199", targetFolder);
+
+ List<String> options = new ArrayList<String>();
+ options.add("-A" + processorClass);
+ final StringBuffer reported = new StringBuffer();
+ BatchTestUtils.compileTree(compiler, options, targetFolder, new DiagnosticListener () {
+ @Override
+ public void report(Diagnostic diag) {
+ reported.append(diag.getMessage(null)).append("\n");
+ }});
+
+ assertEquals(errors, reported.toString());
+ }
@Override
protected void tearDown() throws Exception {

Back to the top