Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2020-08-18 03:55:19 -0400
committerJay Arthanareeswaran2020-08-18 11:24:50 -0400
commit21f3b890e1b29b3110958965c38e0aed5bdc62af (patch)
tree6d242198c45ea1fa2f55c031b438f0d7c51aaba1
parent32841e78082365368261a5aa4052adb44d367cb4 (diff)
downloadeclipse.jdt.core-I20200819-0600.tar.gz
eclipse.jdt.core-I20200819-0600.tar.xz
eclipse.jdt.core-I20200819-0600.zip
Bug 540765 - NullPointerException fromI20200819-1800I20200819-0600I20200818-1800
GeneratedFileManager.saveCompilationUnit Change-Id: I03a900c3e1ca82c20be88695913483826b836514 Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java10
-rw-r--r--org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java26
2 files changed, 35 insertions, 1 deletions
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
index 143cb480f8..4a9a111cb5 100644
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
+++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedFileManager.java
@@ -37,6 +37,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.apt.core.internal.AptPlugin;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.core.internal.Messages;
@@ -534,6 +535,15 @@ public class GeneratedFileManager
// Create the package fragment in the Java Model. This creates all needed parent folders.
IPackageFragment pkgFrag = _CUHELPER.createPackageFragment(pkgName, root, progressMonitor);
+ if (pkgFrag == null) {
+ pkgFrag = root.getPackageFragment(pkgName);
+ // Force an error status
+ IStatus validatePath = root.getJavaProject().getProject().getWorkspace().validatePath(null, IResource.FOLDER);
+ String message = "invalid name for package:" + pkgName; //$NON-NLS-1$
+ AptPlugin.log(new CoreException(validatePath), message);
+ return null;
+ }
+
// Mark all newly created folders (but not pre-existing ones) as derived.
for (IContainer folder : newFolders) {
try {
diff --git a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java
index 1f7ff79f2f..3f32e5ac7f 100644
--- a/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java
+++ b/org.eclipse.jdt.apt.pluggable.tests/src/org/eclipse/jdt/apt/pluggable/tests/FilerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 - 2018 BEA Systems, Inc. and others
+ * Copyright (c) 2007 - 2020 BEA Systems, Inc. and others
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -452,6 +452,30 @@ public class FilerTests extends TestBase
fullBuild();
assertEquals("Processor reported errors", ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
}
+ public void testBug540765() throws Throwable {
+ if (!canRunJava9()) {
+ return;
+ }
+ ProcessorTestStatus.reset();
+ IJavaProject jproj = createJava9Project(_projectName);
+ disableJava5Factories(jproj);
+ IProject proj = jproj.getProject();
+ IPath projPath = proj.getFullPath();
+
+ IPath root = projPath.append("src");
+ env.addClass(root, null, "module-info", "module example {requires annotations;}");
+ env.addClass(root, "p", "Trigger",
+ "package p;\n" +
+ "import org.eclipse.jdt.apt.pluggable.tests.annotations.FilerTestTrigger;\n" +
+ "@FilerTestTrigger(test = \"testBug534979\", arg0 = \"default package\", arg1 = \"Other\")" +
+ "public class Trigger {\n" +
+ "}"
+ );
+
+ AptConfig.setEnabled(jproj, true);
+ fullBuild();
+ assertEquals("Processor reported errors", ProcessorTestStatus.NO_ERRORS, ProcessorTestStatus.getErrors());
+ }
public void _testBug542090() throws Throwable {
if (!canRunJava9()) {
return;

Back to the top