diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 00000000000..0988515fe32
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,13 @@
+name: CodeQL call
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+ schedule:
+ - cron: '45 8 * * 1'
+
+jobs:
+ callCodeQLworkflow:
+ uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/codeQLworkflow.yml@master
diff --git a/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF b/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
index a7624e8329c..e8aa2f7ae66 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
+++ b/apitools/org.eclipse.pde.api.tools.tests/META-INF/MANIFEST.MF
@@ -5,7 +5,6 @@ Bundle-SymbolicName: org.eclipse.pde.api.tools.tests
Bundle-Version: 1.3.200.qualifier
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.core.runtime,
- org.junit,
org.eclipse.pde.api.tools;bundle-version="1.0.600",
org.eclipse.jdt.launching;bundle-version="[3.6.100,4.0.0)",
org.eclipse.debug.core,
@@ -33,15 +32,19 @@ Export-Package: org.eclipse.pde.api.tools.anttasks.tests,
org.eclipse.pde.api.tools.builder.tests.tags,
org.eclipse.pde.api.tools.builder.tests.usage,
org.eclipse.pde.api.tools.comparator.tests,
- org.eclipse.pde.api.tools.model.tests;uses:="junit.framework,org.eclipse.pde.api.tools.model.component",
+ org.eclipse.pde.api.tools.model.tests,
org.eclipse.pde.api.tools.problems.tests,
org.eclipse.pde.api.tools.reference.tests,
org.eclipse.pde.api.tools.search.tests,
org.eclipse.pde.api.tools.tests,
org.eclipse.pde.api.tools.tests.util,
- org.eclipse.pde.api.tools.util.tests;uses:="junit.framework"
+ org.eclipse.pde.api.tools.util.tests
Bundle-Activator: org.eclipse.pde.api.tools.tests.ApiTestsPlugin
Bundle-ActivationPolicy: lazy
Eclipse-BundleShape: dir
-Import-Package: org.eclipse.equinox.frameworkadmin
+Import-Package: junit.framework,
+ org.eclipse.equinox.frameworkadmin,
+ org.junit,
+ org.junit.runner,
+ org.junit.runners
Automatic-Module-Name: org.eclipse.pde.api.tools.tests
diff --git a/apitools/org.eclipse.pde.api.tools.tests/pom.xml b/apitools/org.eclipse.pde.api.tools.tests/pom.xml
index 73c9a0c92c8..b2b61878732 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/pom.xml
+++ b/apitools/org.eclipse.pde.api.tools.tests/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
../../
org.eclipse.pde.api.tools.tests
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiFreezeAntTaskTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiFreezeAntTaskTests.java
index df48aa177dd..51d97f24496 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiFreezeAntTaskTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiFreezeAntTaskTests.java
@@ -24,10 +24,10 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -63,7 +63,7 @@ private void runTaskAndVerify(String resourceName) throws Exception, CoreExcepti
IFile reportFile = buildFolder.getFile("report.xml"); //$NON-NLS-1$
assertTrue("report.xml must exist", reportFile.exists()); //$NON-NLS-1$
InputSource is = new InputSource(reportFile.getContents());
- DocumentBuilder db = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ DocumentBuilder db = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
Document doc = db.parse(is);
NodeList elems = doc.getElementsByTagName("delta"); //$NON-NLS-1$
boolean found = false;
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiuseAntTaskTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiuseAntTaskTests.java
index 808870f866d..2f4c9e24cc0 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiuseAntTaskTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingApiuseAntTaskTests.java
@@ -24,10 +24,10 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -66,7 +66,7 @@ private IFolder runTaskAndVerify(String resourceName) throws Exception, CoreExce
public void test1() throws Exception {
IFolder reportFolder = runTaskAndVerify("test1"); //$NON-NLS-1$
InputSource is = new InputSource(reportFolder.getFile("not_searched.xml").getContents()); //$NON-NLS-1$
- DocumentBuilder db = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ DocumentBuilder db = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
Document doc = db.parse(is);
NodeList elems = doc.getElementsByTagName("component"); //$NON-NLS-1$
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingCompareAntTaskTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingCompareAntTaskTests.java
index 3876e78b9e7..05beea6b9ee 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingCompareAntTaskTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/anttasks/tests/ApiToolingCompareAntTaskTests.java
@@ -22,9 +22,9 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -60,7 +60,7 @@ private void runTaskAndVerify(String resourceName) throws Exception, CoreExcepti
assertTrue("report folder must exist", folder.exists()); //$NON-NLS-1$
assertTrue("report xml must exist", folder.getFile("compare.xml").exists()); //$NON-NLS-1$ //$NON-NLS-2$
InputSource is = new InputSource(folder.getFile("compare.xml").getContents()); //$NON-NLS-1$
- DocumentBuilder db = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ DocumentBuilder db = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
Document doc = db.parse(is);
NodeList elems = doc.getElementsByTagName("delta"); //$NON-NLS-1$
boolean found = false;
diff --git a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java
index aba4dbde919..2e342027acb 100644
--- a/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java
+++ b/apitools/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/util/tests/UtilTests.java
@@ -25,8 +25,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -458,8 +457,7 @@ public boolean isDisposed() {
return false;
}
}
- List allComponents = new ArrayList<>();
- String[] componentNames = new String[] {
+ IApiComponent[] components = Stream.of( //
"org.eclipse.swt", //$NON-NLS-1$
"org.eclipse.equinox.simpleconfigurator.manipulator", //$NON-NLS-1$
"org.eclipse.team.ui", //$NON-NLS-1$
@@ -503,7 +501,6 @@ public boolean isDisposed() {
"org.eclipse.jdt", //$NON-NLS-1$
"org.eclipse.osgi.util", //$NON-NLS-1$
"org.sat4j.pb", //$NON-NLS-1$
- "org.hamcrest.core", //$NON-NLS-1$
"org.eclipse.jdt.junit4.runtime", //$NON-NLS-1$
"org.eclipse.equinox.p2.artifact.repository", //$NON-NLS-1$
"org.eclipse.core.databinding.property", //$NON-NLS-1$
@@ -644,13 +641,8 @@ public boolean isDisposed() {
"org.eclipse.equinox.app", //$NON-NLS-1$
"org.eclipse.ui.net", //$NON-NLS-1$
"org.eclipse.equinox.p2.publisher", //$NON-NLS-1$
- "org.eclipse.ecf.provider.filetransfer.httpclient", //$NON-NLS-1$
- };
- for (String componentName : componentNames) {
- allComponents.add(new LocalApiComponent(componentName));
- }
- IApiComponent[] components = new IApiComponent[allComponents.size()];
- allComponents.toArray(components);
+ "org.eclipse.ecf.provider.filetransfer.httpclient" //$NON-NLS-1$
+ ).map(LocalApiComponent::new).toArray(IApiComponent[]::new);
FilteredElements excludedElements = new FilteredElements();
try {
Util.collectRegexIds(line, excludedElements, components, false);
diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java
index ad13db74ab1..986ea4ee42e 100644
--- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java
+++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ExportSessionAction.java
@@ -27,6 +27,7 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -45,7 +46,6 @@
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
import org.eclipse.pde.api.tools.ui.internal.IApiToolsConstants;
import org.eclipse.pde.api.tools.ui.internal.views.APIToolingView;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
/**
* Drop-down action to select the active session.
@@ -155,7 +155,7 @@ protected IStatus run(IProgressMonitor monitor) {
}
writer = new BufferedWriter(new FileWriter(reportFile));
Result result = new StreamResult(writer);
- TransformerFactory f = PDEXmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE();
+ TransformerFactory f = XmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE();
Transformer trans = f.newTransformer(xsltSource);
trans.transform(xmlSource, result);
} catch (TransformerException | IOException e) {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java
index 377907f9e87..cfb266779dd 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/APIFileGenerator.java
@@ -14,7 +14,6 @@
package org.eclipse.pde.api.tools.internal;
import java.io.BufferedInputStream;
-import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
@@ -46,7 +45,6 @@
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.scanner.TagScanner;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.xml.sax.Attributes;
@@ -458,27 +456,16 @@ private boolean isAPIToolsNature(File dotProjectFile) {
* @return true if it contains a source extension point, false otherwise
*/
private boolean containsAPIToolsNature(String pluginXMLContents) {
- SAXParser saxParser = null;
- try {
- saxParser = PDEXmlProcessorFactory.createSAXParserIgnoringDOCTYPE();
- } catch (ParserConfigurationException | SAXException e) {
- // ignore
- }
-
- if (saxParser == null) {
- return false;
- }
-
- // Parse
- InputSource inputSource = new InputSource(new BufferedReader(new StringReader(pluginXMLContents)));
try {
+ @SuppressWarnings("restriction")
+ SAXParser saxParser = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createSAXParserIgnoringDOCTYPE();
APIToolsNatureDefaultHandler defaultHandler = new APIToolsNatureDefaultHandler();
- saxParser.parse(inputSource, defaultHandler);
+ saxParser.parse(new InputSource(new StringReader(pluginXMLContents)), defaultHandler);
return defaultHandler.isAPIToolsNature();
- } catch (SAXException | IOException e) {
- // ignore
+ } catch (SAXException | IOException | ParserConfigurationException e) {
+ return false;
}
- return false;
}
}
\ No newline at end of file
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnalysisApplication.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnalysisApplication.java
index 34e7d98b1a6..b5342a24dcd 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnalysisApplication.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnalysisApplication.java
@@ -127,6 +127,11 @@ public Object start(IApplicationContext context) throws Exception {
setTargetPlatform(args.tpFile);
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ // wait untill all jobs has finished that might be sceduled as part of the
+ // build...
+ while (!Job.getJobManager().isIdle()) {
+ Thread.yield();
+ }
IMarker[] allProblemMarkers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
Predicate isAPIMarker = marker -> {
try {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnnotations.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnnotations.java
index 74703a72282..a6ae6501d69 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnnotations.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiAnnotations.java
@@ -57,8 +57,7 @@ public String toString() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof ApiAnnotations) {
- ApiAnnotations desc = (ApiAnnotations) obj;
+ if (obj instanceof ApiAnnotations desc) {
return this.bits == desc.bits;
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java
index c60ec2e6927..b5cc11bac6b 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiBaselineManager.java
@@ -63,7 +63,6 @@
import org.eclipse.pde.core.plugin.ModelEntry;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.DependencyManager;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -373,7 +372,7 @@ private void writeBaselineDescription(IApiBaseline baseline, OutputStream stream
try {
stream.write(xml.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
- abort("Error writing pofile descrition", e); //$NON-NLS-1$
+ throw new CoreException(Status.error("Error writing pofile descrition", e)); //$NON-NLS-1$
}
}
@@ -422,18 +421,6 @@ private String getProfileXML(IApiBaseline baseline) throws CoreException {
return Util.serializeDocument(document);
}
- /**
- * Throws a core exception with the given message and underlying exception,
- * if any.
- *
- * @param message error message
- * @param e underlying exception or null
- * @throws CoreException
- */
- private static void abort(String message, Throwable e) throws CoreException {
- throw new CoreException(Status.error(message, e));
- }
-
/**
* Restore a baseline from the given input stream (persisted baseline).
*
@@ -444,14 +431,8 @@ private static void abort(String message, Throwable e) throws CoreException {
*/
public IApiComponent[] readBaselineComponents(ApiBaseline baseline, InputStream stream) throws CoreException {
long start = System.currentTimeMillis();
- DocumentBuilder parser = null;
+ DocumentBuilder parser = getConfiguredParser();
IApiComponent[] restored = null;
- try {
- parser = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
- parser.setErrorHandler(new DefaultHandler());
- } catch (ParserConfigurationException | FactoryConfigurationError e) {
- abort("Error restoring API baseline", e); //$NON-NLS-1$
- }
try {
Document document = parser.parse(stream);
Element root = document.getDocumentElement();
@@ -505,7 +486,7 @@ public IApiComponent[] readBaselineComponents(ApiBaseline baseline, InputStream
restored = components.toArray(new IApiComponent[components.size()]);
}
} catch (IOException | SAXException e) {
- abort("Error restoring API baseline", e); //$NON-NLS-1$
+ throw new CoreException(Status.error("Error restoring API baseline", e)); //$NON-NLS-1$
}
if (ApiPlugin.DEBUG_BASELINE_MANAGER) {
System.out.println("Time to restore a persisted baseline : " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -513,6 +494,18 @@ public IApiComponent[] readBaselineComponents(ApiBaseline baseline, InputStream
return restored;
}
+ private static DocumentBuilder getConfiguredParser() throws CoreException {
+ try {
+ @SuppressWarnings("restriction")
+ DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createDocumentBuilderWithErrorOnDOCTYPE();
+ parser.setErrorHandler(new DefaultHandler());
+ return parser;
+ } catch (ParserConfigurationException | FactoryConfigurationError e) {
+ throw new CoreException(Status.error("Error restoring API baseline", e)); //$NON-NLS-1$
+ }
+ }
+
@Override
public void saving(ISaveContext context) throws CoreException {
if (!fNeedsSaving) {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java
index 7cd5641b508..ef227a61c39 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/ApiDescriptionManager.java
@@ -356,8 +356,7 @@ private void restoreNode(ProjectApiDescription apiDesc, Element element, Manifes
break;
}
case IApiXmlConstants.ELEMENT_FIELD:
- if (parentNode.element instanceof IReferenceTypeDescriptor) {
- IReferenceTypeDescriptor type = (IReferenceTypeDescriptor) parentNode.element;
+ if (parentNode.element instanceof IReferenceTypeDescriptor type) {
int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY);
int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS);
String name = element.getAttribute(IApiXmlConstants.ATTR_NAME);
@@ -366,8 +365,7 @@ private void restoreNode(ProjectApiDescription apiDesc, Element element, Manifes
}
break;
case IApiXmlConstants.ELEMENT_METHOD:
- if (parentNode.element instanceof IReferenceTypeDescriptor) {
- IReferenceTypeDescriptor type = (IReferenceTypeDescriptor) parentNode.element;
+ if (parentNode.element instanceof IReferenceTypeDescriptor type) {
int vis = getInt(element, IApiXmlConstants.ATTR_VISIBILITY);
int res = getInt(element, IApiXmlConstants.ATTR_RESTRICTIONS);
String name = element.getAttribute(IApiXmlConstants.ATTR_NAME);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/BundleVersionRange.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/BundleVersionRange.java
index c641dbc753a..7f2a837c96a 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/BundleVersionRange.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/BundleVersionRange.java
@@ -68,8 +68,7 @@ public boolean isIncludeMinimum() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof BundleVersionRange) {
- BundleVersionRange range = (BundleVersionRange) obj;
+ if (obj instanceof BundleVersionRange range) {
return fRange.equals(range.fRange);
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
index d84fa66e474..4bc9cd9a0fb 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/JavadocTagManager.java
@@ -50,8 +50,7 @@ public Key(int t, int m) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof Key) {
- Key other = (Key) obj;
+ if (obj instanceof Key other) {
return type == other.type && member == other.member;
}
return super.equals(obj);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/RequiredComponentDescription.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/RequiredComponentDescription.java
index cf1297292dd..41e021c0a87 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/RequiredComponentDescription.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/RequiredComponentDescription.java
@@ -59,8 +59,7 @@ public RequiredComponentDescription(String id, IVersionRange range, boolean isOp
@Override
public boolean equals(Object obj) {
- if (obj instanceof RequiredComponentDescription) {
- RequiredComponentDescription desc = (RequiredComponentDescription) obj;
+ if (obj instanceof RequiredComponentDescription desc) {
return fId.equals(desc.fId) && fRange.equals(desc.fRange);
}
return super.equals(obj);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java
index e0fd2244ba4..bc2b57d84c2 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractIllegalMethodReference.java
@@ -74,8 +74,7 @@ public boolean considerReference(IReference reference, IProgressMonitor monitor)
} catch (CoreException ce) {
// do nothing, skip it
}
- if (member instanceof IApiMethod) {
- IApiMethod method = (IApiMethod) member;
+ if (member instanceof IApiMethod method) {
if (method.isDefaultMethod()) {
return considerReference(reference, monitor);
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
index 9f15fb0f21d..34244994a38 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/AbstractProblemDetector.java
@@ -517,8 +517,7 @@ public List createProblems(IProgressMonitor monitor) {
IApiComponent component = reference.getMember().getApiComponent();
try {
IApiProblem problem = null;
- if (component instanceof ProjectComponent) {
- ProjectComponent ppac = (ProjectComponent) component;
+ if (component instanceof ProjectComponent ppac) {
IJavaProject project = ppac.getJavaProject();
problem = createProblem(reference, project);
} else {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder.java
index 4d4238e9c13..b6845ac9e00 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder.java
@@ -629,10 +629,9 @@ public boolean contains(ISchedulingRule rule) {
@Override
public boolean isConflicting(ISchedulingRule rule) {
- if (!(rule instanceof ApiAnalysisJobRule)) {
+ if (!(rule instanceof ApiAnalysisJobRule other)) {
return false;
}
- ApiAnalysisJobRule other = (ApiAnalysisJobRule) rule;
return project.equals(other.project);
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java
index 18880b7e16a..369366baea0 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java
@@ -2666,8 +2666,7 @@ public void checkBaselineMismatch(IApiBaseline baseline, IApiBaseline workspaceB
* @return Java project or null
*/
private IJavaProject getJavaProject(IApiComponent component) {
- if (component instanceof ProjectComponent) {
- ProjectComponent pp = (ProjectComponent) component;
+ if (component instanceof ProjectComponent pp) {
return pp.getJavaProject();
}
return null;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder.java
index 17409b7b6df..689145282e2 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder.java
@@ -166,8 +166,7 @@ public boolean visit(IResourceDelta delta) throws CoreException {
if (component != null) {
try {
IApiAnnotations annotations = component.getApiDescription().resolveAnnotations(Factory.typeDescriptor(type.replace('/', '.')));
- if (annotations instanceof TypeAnnotations) {
- TypeAnnotations ta = (TypeAnnotations) annotations;
+ if (annotations instanceof TypeAnnotations ta) {
if (ta.getBuildStamp() == BuildStamps.getBuildStamp(resource.getProject())) {
// note description change in
// addition to structure
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
index f05c4ba30bd..0bb636b4166 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ProblemDetectorBuilder.java
@@ -197,8 +197,7 @@ public void setOwningComponent(IApiComponent component) {
* not a {@link PluginProjectApiComponent}
*/
private IProject getProject(IApiComponent component) {
- if (component instanceof ProjectComponent) {
- ProjectComponent comp = (ProjectComponent) component;
+ if (component instanceof ProjectComponent comp) {
return comp.getJavaProject().getProject();
}
return null;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java
index 2d35c700a17..3cd2fde2ab5 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/ReferenceExtractor.java
@@ -417,8 +417,7 @@ && getDefaultDefined(type, name, desc, false) != null) {
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
for (Object arg : bsmArgs) {
- if (arg instanceof Handle) {
- Handle handle = (Handle) arg;
+ if (arg instanceof Handle handle) {
Type declaringType = Type.getObjectType(handle.getOwner());
Reference reference = ReferenceExtractor.this.addMethodReference(declaringType, handle.getName(), handle.getDesc(), IReference.REF_VIRTUALMETHOD, 0);
if (reference != null) {
@@ -564,14 +563,12 @@ public void visitLocalVariable(String name, String desc, String signature, Label
@Override
public void visitLdcInsn(Object cst) {
- if (cst instanceof Type) {
- Type type = (Type) cst;
+ if (cst instanceof Type type) {
Reference reference = ReferenceExtractor.this.addTypeReference(type, IReference.REF_CONSTANTPOOL);
if (reference != null) {
this.linePositionTracker.addLocation(reference);
}
- } else if (cst instanceof String) {
- String str = (String) cst;
+ } else if (cst instanceof String str) {
this.stringLiteral = (Util.EMPTY_STRING.equals(str) ? null : str);
}
}
@@ -762,15 +759,13 @@ public void computeLineNumbers() {
remainingCatchLabelInfos = remaingEntriesTemp;
}
}
- } else if (current instanceof Reference) {
- Reference ref = (Reference) current;
+ } else if (current instanceof Reference ref) {
if (ref.getLineNumber() == -1) {
ref.setLineNumber(currentLineNumber);
} else {
currentLineNumber = ref.getLineNumber();
}
- } else if (current instanceof LineInfo) {
- LineInfo lineInfo = (LineInfo) current;
+ } else if (current instanceof LineInfo lineInfo) {
currentLineNumber = lineInfo.line;
}
}
@@ -810,8 +805,7 @@ public int compareTo(Object o) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof LineInfo) {
- LineInfo lineInfo2 = (LineInfo) obj;
+ if (obj instanceof LineInfo lineInfo2) {
return this.line == lineInfo2.line && this.label.equals(lineInfo2.label);
}
return super.equals(obj);
@@ -841,8 +835,7 @@ public LocalLineNumberMarker(int line, int varIndex) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof LocalLineNumberMarker) {
- LocalLineNumberMarker marker = (LocalLineNumberMarker) obj;
+ if (obj instanceof LocalLineNumberMarker marker) {
return this.lineNumber == marker.lineNumber && this.varIndex == marker.varIndex;
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java
index ded068a580a..c4e7fba1f33 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/SystemApiDetector.java
@@ -393,8 +393,7 @@ public List createProblems(IProgressMonitor monitor) {
try {
IApiProblem problem = null;
IApiComponent component = reference.getMember().getApiComponent();
- if (component instanceof ProjectComponent) {
- ProjectComponent ppac = (ProjectComponent) component;
+ if (component instanceof ProjectComponent ppac) {
IJavaProject project = ppac.getJavaProject();
problem = createProblem(reference, project);
} else {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Validator.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Validator.java
index 54a7fd2f400..01c71c0049a 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Validator.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/builder/Validator.java
@@ -210,8 +210,7 @@ protected int getParentModifiers(ASTNode node) {
if (node == null) {
return 0;
}
- if (node instanceof AbstractTypeDeclaration) {
- AbstractTypeDeclaration type = (AbstractTypeDeclaration) node;
+ if (node instanceof AbstractTypeDeclaration type) {
return type.getModifiers();
}
return getParentModifiers(node.getParent());
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/Delta.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/Delta.java
index 1f6ea1fc533..ececc8a5de1 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/Delta.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/Delta.java
@@ -187,10 +187,9 @@ public boolean equals(Object obj) {
if (obj == null) {
return false;
}
- if (!(obj instanceof Delta)) {
+ if (!(obj instanceof Delta other)) {
return false;
}
- Delta other = (Delta) obj;
if (this.elementType != other.elementType) {
return false;
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/FieldDescriptorImpl.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/FieldDescriptorImpl.java
index 4a22fc67316..0981d2e6eff 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/FieldDescriptorImpl.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/FieldDescriptorImpl.java
@@ -46,8 +46,7 @@ public String toString() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IFieldDescriptor) {
- IFieldDescriptor field = (IFieldDescriptor) obj;
+ if (obj instanceof IFieldDescriptor field) {
return getName().equals(field.getName()) && getEnclosingType().equals(field.getEnclosingType());
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/MethodDescriptorImpl.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/MethodDescriptorImpl.java
index ca63d0e8a67..7ce2b4743c8 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/MethodDescriptorImpl.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/MethodDescriptorImpl.java
@@ -53,8 +53,7 @@ public String toString() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IMethodDescriptor) {
- IMethodDescriptor method = (IMethodDescriptor) obj;
+ if (obj instanceof IMethodDescriptor method) {
return getName().equals(method.getName()) && getEnclosingType().equals(method.getEnclosingType()) && getSignature().equals(method.getSignature());
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/PackageDescriptorImpl.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/PackageDescriptorImpl.java
index d1954a1072c..91865439702 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/PackageDescriptorImpl.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/PackageDescriptorImpl.java
@@ -41,8 +41,7 @@ public String toString() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IPackageDescriptor) {
- IPackageDescriptor pkg = (IPackageDescriptor) obj;
+ if (obj instanceof IPackageDescriptor pkg) {
return getName().equals(pkg.getName());
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/ReferenceTypeDescriptorImpl.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/ReferenceTypeDescriptorImpl.java
index 1322d4bf50b..79b661b20ea 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/ReferenceTypeDescriptorImpl.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/descriptors/ReferenceTypeDescriptorImpl.java
@@ -118,8 +118,7 @@ public synchronized String getQualifiedName() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IReferenceTypeDescriptor) {
- IReferenceTypeDescriptor refType = (IReferenceTypeDescriptor) obj;
+ if (obj instanceof IReferenceTypeDescriptor refType) {
return getQualifiedName().equals(refType.getQualifiedName());
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
index 45170bc9d2f..3e087082519 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiBaseline.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2022 IBM Corporation and others.
+ * Copyright (c) 2007, 2023 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -290,21 +290,18 @@ public static Properties getJavaProfileProperties(String ee) {
*/
@SuppressWarnings("deprecation")
private void initialize(Properties profile, ExecutionEnvironmentDescription description) throws CoreException {
- String value = profile.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
- if (value == null) {
- // In Java-10 and beyond, we query system-packages list from the JRE
- String environmentId = description.getProperty(ExecutionEnvironmentDescription.CLASS_LIB_LEVEL);
- IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
- IExecutionEnvironment environment = manager.getEnvironment(environmentId);
- value = TargetPlatformHelper.querySystemPackages(environment);
- }
+ String environmentId = description.getProperty(ExecutionEnvironmentDescription.CLASS_LIB_LEVEL);
+ IExecutionEnvironment ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(environmentId);
+ String value = TargetPlatformHelper.getSystemPackages(ee, profile);
String[] systemPackages = null;
if (value != null) {
systemPackages = value.split(","); //$NON-NLS-1$
}
if (!(this instanceof WorkspaceBaseline)) {
Dictionary dictionary = new Hashtable<>();
- dictionary.put(Constants.FRAMEWORK_SYSTEMPACKAGES, value);
+ if (value != null) {
+ dictionary.put(Constants.FRAMEWORK_SYSTEMPACKAGES, value);
+ }
value = profile.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
if (value != null) {
dictionary.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, value);
@@ -396,8 +393,7 @@ protected void addComponent(IApiComponent component) {
}
fComponentsById.put(component.getSymbolicName(), component);
- if (component instanceof ProjectComponent) {
- ProjectComponent projectApiComponent = (ProjectComponent) component;
+ if (component instanceof ProjectComponent projectApiComponent) {
if (this.fComponentsByProjectNames == null) {
this.fComponentsByProjectNames = new HashMap<>();
}
@@ -805,8 +801,7 @@ public void setName(String name) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IApiBaseline) {
- IApiBaseline baseline = (IApiBaseline) obj;
+ if (obj instanceof IApiBaseline baseline) {
return this.getName().equals(baseline.getName());
}
return super.equals(obj);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiMember.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiMember.java
index e5a5e6dc6b9..74528182329 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiMember.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiMember.java
@@ -99,8 +99,7 @@ public String getPackageName() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IApiElement) {
- IApiElement element = (IApiElement) obj;
+ if (obj instanceof IApiElement element) {
if (element.getType() == this.getType()) {
return enclosingTypesEqual(this, element) && getName().equals(element.getName());
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiType.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiType.java
index f124b311657..bfea24f05ae 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiType.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ApiType.java
@@ -321,8 +321,7 @@ private void reOrganizeComponents(IApiComponent[] components) throws CoreExcepti
if (javaEE != null) {
for (int i = 0; i < components.length; i++) {
IApiComponent iComponent = components[i];
- if (iComponent instanceof SystemLibraryApiComponent) {
- SystemLibraryApiComponent sysCom = (SystemLibraryApiComponent) iComponent;
+ if (iComponent instanceof SystemLibraryApiComponent sysCom) {
if (sysCom.getSymbolicName().equals(javaEE)) {
// swap i and 0;
IApiComponent temp = components[i];
@@ -495,8 +494,7 @@ public IMemberDescriptor getHandle() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IApiType) {
- IApiType type = (IApiType) obj;
+ if (obj instanceof IApiType type) {
if (getApiComponent() == null) {
return type.getApiComponent() == null && getName().equals(type.getName());
}
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ArchiveApiTypeContainer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ArchiveApiTypeContainer.java
index 42732186ea7..6bb37240aec 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ArchiveApiTypeContainer.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ArchiveApiTypeContainer.java
@@ -81,8 +81,7 @@ public int compareTo(Object o) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof ArchiveApiTypeRoot) {
- ArchiveApiTypeRoot classFile = (ArchiveApiTypeRoot) obj;
+ if (obj instanceof ArchiveApiTypeRoot classFile) {
return this.getName().equals(classFile.getName());
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java
index b837c68809b..7f1bbe469cb 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.pde.api.tools.internal.model;
-import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -77,7 +76,6 @@
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.internal.core.TargetWeaver;
import org.eclipse.pde.internal.core.util.ManifestUtils;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -260,8 +258,7 @@ public boolean isValidBundle() throws CoreException {
@Override
public boolean equals(Object obj) {
- if (obj instanceof BundleComponent) {
- BundleComponent comp = (BundleComponent) obj;
+ if (obj instanceof BundleComponent comp) {
return getName().equals(comp.getName()) && getSymbolicName().equals(comp.getSymbolicName()) && getVersion().equals(comp.getVersion());
}
return false;
@@ -1067,27 +1064,16 @@ private static boolean isSourceComponent(Map manifest, File loca
* @return true if it contains a source extension point, false otherwise
*/
private static boolean containsSourceExtensionPoint(String pluginXMLContents) {
- SAXParser saxParser = null;
- try {
- saxParser = PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
- } catch (ParserConfigurationException | SAXException e) {
- // ignore
- }
-
- if (saxParser == null) {
- return false;
- }
-
- // Parse
- InputSource inputSource = new InputSource(new BufferedReader(new StringReader(pluginXMLContents)));
try {
+ @SuppressWarnings("restriction")
+ SAXParser saxParser = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createSAXParserWithErrorOnDOCTYPE();
SourceDefaultHandler defaultHandler = new SourceDefaultHandler();
- saxParser.parse(inputSource, defaultHandler);
+ saxParser.parse(new InputSource(new StringReader(pluginXMLContents)), defaultHandler);
return defaultHandler.isSource();
- } catch (SAXException | IOException e) {
- // ignore
+ } catch (SAXException | IOException | ParserConfigurationException e) {
+ return false;
}
- return false;
}
@Override
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/MethodKey.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/MethodKey.java
index 8c00687ed1d..5994c89ba9d 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/MethodKey.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/MethodKey.java
@@ -44,8 +44,7 @@ public MethodKey(String typename, String name, String sig, boolean considertypen
@Override
public boolean equals(Object obj) {
- if (obj instanceof MethodKey) {
- MethodKey key = (MethodKey) obj;
+ if (obj instanceof MethodKey key) {
return fSelector.equals(key.fSelector) && signaturesEqual(fSig, key.fSig) && (fConsiderTypename ? fTypename.equals(key.fTypename) : true);
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java
index af7a190d554..fcc8e9e0d26 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java
@@ -96,8 +96,7 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IApiTypeRoot) {
- IApiTypeRoot file = (IApiTypeRoot) obj;
+ if (obj instanceof IApiTypeRoot file) {
return getName().equals(file.getTypeName());
}
return super.equals(obj);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java
index f609a3d8e9b..1c0062e8111 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/StubArchiveApiTypeContainer.java
@@ -79,8 +79,7 @@ public int compareTo(Object o) {
@Override
public boolean equals(Object obj) {
- if (obj instanceof ArchiveApiTypeRoot) {
- ArchiveApiTypeRoot classFile = (ArchiveApiTypeRoot) obj;
+ if (obj instanceof ArchiveApiTypeRoot classFile) {
return this.getName().equals(classFile.getName());
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java
index b492b6c19d9..c4d5523c02d 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java
@@ -282,8 +282,7 @@ public static IApiType buildTypeStructure(byte[] bytes, IApiComponent component,
*/
public static void setEnclosingMethod(IApiType enclosingType, ApiType currentAnonymousLocalType) {
IApiTypeRoot typeRoot = enclosingType.getTypeRoot();
- if (typeRoot instanceof AbstractApiTypeRoot) {
- AbstractApiTypeRoot abstractApiTypeRoot = (AbstractApiTypeRoot) typeRoot;
+ if (typeRoot instanceof AbstractApiTypeRoot abstractApiTypeRoot) {
EnclosingMethodSetter visitor = new EnclosingMethodSetter(new ClassNode(), currentAnonymousLocalType.getName());
try {
ClassReader classReader = new ClassReader(abstractApiTypeRoot.getContents());
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblem.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblem.java
index 977841be7ba..c189f0d1047 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblem.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblem.java
@@ -209,8 +209,7 @@ public String[] getMessageArguments() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IApiProblem) {
- IApiProblem problem = (IApiProblem) obj;
+ if (obj instanceof IApiProblem problem) {
if (problem.getId() == fId && argumentsEqual(problem.getMessageArguments())) {
String resourcePath = problem.getResourcePath();
if (resourcePath == null) {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFilter.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFilter.java
index e70706048d7..97da369e9f9 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFilter.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/problems/ApiProblemFilter.java
@@ -68,8 +68,7 @@ public String getComponentId() {
@Override
public boolean equals(Object obj) {
- if (obj instanceof IApiProblemFilter) {
- IApiProblemFilter filter = (IApiProblemFilter) obj;
+ if (obj instanceof IApiProblemFilter filter) {
return elementsEqual(filter.getComponentId(), fComponentId) && filter.getUnderlyingProblem().equals(fProblem);
} else if (obj instanceof IApiProblem) {
return fProblem.equals(obj);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java
index a976b3a3392..55094446bc9 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/provisional/scanner/TagScanner.java
@@ -245,8 +245,7 @@ void scanMethodAnnotation(String name, MethodDeclaration node) {
if (JavadocTagManager.ANNOTATION_NOOVERRIDE.equals(name)) {
if (!Flags.isFinal(node.getModifiers()) && !Flags.isStatic(node.getModifiers())) {
ASTNode parent = node.getParent();
- if (parent instanceof TypeDeclaration) {
- TypeDeclaration type = (TypeDeclaration) parent;
+ if (parent instanceof TypeDeclaration type) {
if (type.isInterface()) {
if (Flags.isDefaultMethod(node.getModifiers())) {
restrictions |= RestrictionModifiers.NO_OVERRIDE;
@@ -480,8 +479,7 @@ public boolean visit(PackageDeclaration node) {
public boolean visit(MethodDeclaration node) {
if (isNotVisible(node.getModifiers())) {
ASTNode parent = node.getParent();
- if (parent instanceof TypeDeclaration) {
- TypeDeclaration type = (TypeDeclaration) parent;
+ if (parent instanceof TypeDeclaration type) {
if (!type.isInterface()) {
return false;
}
@@ -532,8 +530,7 @@ void scanMethodJavaDoc(MethodDeclaration node) {
continue;
}
ASTNode parent = node.getParent();
- if (parent instanceof TypeDeclaration) {
- TypeDeclaration type = (TypeDeclaration) parent;
+ if (parent instanceof TypeDeclaration type) {
if (type.isInterface()) {
if (Flags.isDefaultMethod(node.getModifiers())) {
restrictions |= RestrictionModifiers.NO_OVERRIDE;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor.java
index 30c604f9d4b..0c3177cec88 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ConsumerReportConvertor.java
@@ -512,8 +512,7 @@ protected void writeIndexPage(List> scanResult) throws Exception {
File refereehtml = null;
String link = null;
for (Object obj : scanResult) {
- if (obj instanceof Consumer) {
- Consumer consumer = (Consumer) obj;
+ if (obj instanceof Consumer consumer) {
refereehtml = new File(getReportsRoot(), consumer.name + File.separator + "index.html"); //$NON-NLS-1$
link = extractLinkFrom(getReportsRoot(), refereehtml.getAbsolutePath());
buffer.append(getReferenceTableEntry(consumer.counts, link, consumer.name, true));
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java
index f0423499002..3eb781720fd 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefParser.java
@@ -118,7 +118,8 @@ public void parse(String xmlLocation, MissingRefVisitor visitor) throws Exceptio
components = sort(components);
visitor.visitScan();
- SAXParser parser = getParser();
+ @SuppressWarnings("restriction")
+ SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
// Treat each top level directory as a producer component
for (File component : components) {
if (component.isDirectory()) {
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java
index 85a55ef010c..da746312edc 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/MissingRefReportConverter.java
@@ -374,8 +374,7 @@ protected void writeIndexPage(List> result) throws Exception {
buffer.append(getProblemSummaryTable());
if (result.size() > 0) {
for (Object obj : result) {
- if (obj instanceof Report) {
- Report report = (Report) obj;
+ if (obj instanceof Report report) {
File refereehtml = new File(getReportsRoot(), report.name + File.separator + "index.html"); //$NON-NLS-1$
String link = extractLinkFrom(getReportsRoot(), refereehtml.getAbsolutePath());
buffer.append(getReferenceTableEntry(report, link));
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ReferenceDescriptor.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ReferenceDescriptor.java
index 879df3943dd..d4c990ad703 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ReferenceDescriptor.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/ReferenceDescriptor.java
@@ -48,8 +48,7 @@ public ReferenceDescriptor(IComponentDescriptor from, IMemberDescriptor origin,
@Override
public boolean equals(Object obj) {
- if (obj instanceof ReferenceDescriptor) {
- ReferenceDescriptor rd = (ReferenceDescriptor) obj;
+ if (obj instanceof ReferenceDescriptor rd) {
return origin.equals(rd.origin) && target.equals(rd.target) && from.equals(rd.from) && to.equals(rd.to) && line == rd.line && kind == rd.kind && visibility == rd.visibility;
}
return false;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java
index b7e0c302485..ab9cd7aa34c 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/SearchMessages.java
@@ -104,8 +104,6 @@ public class SearchMessages extends NLS {
public static String UseReportConverter_scan_date;
public static String UseReportConverter_scan_details;
public static String UseReportConverter_scope_pattern;
- public static String UseReportConverter_se_error_parser_handle;
- public static String UseReportConverter_pce_error_getting_parser;
public static String UseReportConverter_preparing_html_root;
public static String UseReportConverter_preparing_report_metadata;
public static String UseReportConverter_preparing_xml_root;
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseReportConverter.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseReportConverter.java
index a1ec2ebd4d1..32caaf12a4b 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseReportConverter.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseReportConverter.java
@@ -42,7 +42,6 @@
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
@@ -65,7 +64,6 @@
import org.eclipse.pde.api.tools.internal.provisional.search.IMetadata;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.osgi.framework.Version;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -738,18 +736,10 @@ protected List> parse(IProgressMonitor monitor) throws Exception {
* @throws Exception forwarded general exception that can be trapped in Ant
* builds
*/
- SAXParser getParser() throws Exception {
+ @SuppressWarnings("restriction")
+ private SAXParser getParser() throws ParserConfigurationException, SAXException {
if (this.parser == null) {
- try {
- this.parser = PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
- } catch (ParserConfigurationException pce) {
- throw new Exception(SearchMessages.UseReportConverter_pce_error_getting_parser, pce);
- } catch (SAXException se) {
- throw new Exception(SearchMessages.UseReportConverter_se_error_parser_handle, se);
- }
- if (this.parser == null) {
- throw new Exception(SearchMessages.could_not_create_sax_parser);
- }
+ this.parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
}
return this.parser;
}
@@ -819,8 +809,9 @@ protected void applyXSLT(File xsltFile, File xmlfile, File htmloutput) throws Tr
protected void applyXSLT(Source xslt, File xmlfile, File htmlfile) throws TransformerException {
Source xml = new StreamSource(xmlfile);
Result html = new StreamResult(htmlfile);
- TransformerFactory factory = PDEXmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE();
- Transformer former = factory.newTransformer(xslt);
+ @SuppressWarnings("restriction")
+ Transformer former = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createTransformerFactoryWithErrorOnDOCTYPE().newTransformer(xslt);
former.transform(xml, html);
}
@@ -1463,8 +1454,7 @@ protected void writeIndexPage(List> scanResult) throws Exception {
File refereehtml = null;
String link = null;
for (Object obj : scanResult) {
- if (obj instanceof Report) {
- Report report = (Report) obj;
+ if (obj instanceof Report report) {
refereehtml = new File(getReportsRoot(), report.name + File.separator + "index.html"); //$NON-NLS-1$
link = extractLinkFrom(getReportsRoot(), refereehtml.getAbsolutePath());
buffer.append(getReferenceTableEntry(report.counts, link, report.name, true));
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseScanParser.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseScanParser.java
index 1ed33e3d82f..2fb02a1ae11 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseScanParser.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/UseScanParser.java
@@ -22,7 +22,6 @@
import java.util.Collections;
import java.util.List;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -35,7 +34,6 @@
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -244,7 +242,9 @@ public void parse(String xmlLocation, IProgressMonitor monitor, UseScanVisitor u
localmonitor.setWorkRemaining(referees.length);
visitor.visitScan();
try {
- SAXParser parser = getParser();
+ @SuppressWarnings("restriction")
+ SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createSAXParserWithErrorOnDOCTYPE();
// Treat each top level directory as a producer component
for (File referee : referees) {
if (referee.isDirectory()) {
@@ -299,24 +299,6 @@ public void parse(String xmlLocation, IProgressMonitor monitor, UseScanVisitor u
}
}
- /**
- * Returns a parser
- *
- * @return default parser
- * @throws Exception forwarded general exception that can be trapped in Ant
- * builds
- */
- SAXParser getParser() throws Exception {
- try {
- return PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
-
- } catch (ParserConfigurationException pce) {
- throw new Exception(SearchMessages.UseReportConverter_pce_error_getting_parser, pce);
- } catch (SAXException se) {
- throw new Exception(SearchMessages.UseReportConverter_se_error_parser_handle, se);
- }
- }
-
/**
* @return the referencingComponent or null
*/
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter.java
index 7510d089bee..c72065ce5fa 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter.java
@@ -46,7 +46,6 @@
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -84,10 +83,11 @@ public class XmlReferenceDescriptorWriter {
* to write the reports to
* @param debug if debugging infos should be written out to the console
*/
+ @SuppressWarnings("restriction")
public XmlReferenceDescriptorWriter(String location) {
fLocation = location;
try {
- parser = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
parser.setErrorHandler(new DefaultHandler());
} catch (FactoryConfigurationError | ParserConfigurationException pce) {
ApiPlugin.log(pce);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java
index aa7a2cdbc7a..bfb82c411ce 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/XmlSearchReporter.java
@@ -39,7 +39,6 @@
import org.eclipse.pde.api.tools.internal.provisional.search.IApiSearchReporter;
import org.eclipse.pde.api.tools.internal.provisional.search.IMetadata;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.helpers.DefaultHandler;
@@ -65,11 +64,12 @@ public class XmlSearchReporter implements IApiSearchReporter {
* to write the reports to
* @param debug if debugging infos should be written out to the console
*/
+ @SuppressWarnings("restriction")
public XmlSearchReporter(String location, boolean debug) {
fLocation = location;
this.debug = debug;
try {
- parser = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
parser.setErrorHandler(new DefaultHandler());
} catch (FactoryConfigurationError | ParserConfigurationException pce) {
ApiPlugin.log(pce);
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties
index 583fc97a0a9..6baed83d1d4 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/search/searchmessages.properties
@@ -91,14 +91,12 @@ SkippedComponent_component_was_excluded=This component was excluded from the sea
UseReportConverter_scan_date=Date of the Scan:
UseReportConverter_scan_details=Scan Details
UseReportConverter_scope_pattern=Scope Pattern:
-UseReportConverter_se_error_parser_handle=SAXException trying to get handle to the default parser.
UseReportConverter_collecting_dir_info=Collecting directory information...
UseReportConverter_core_exep_reading_metadata=CoreException parsing XML file: {0}
UseReportConverter_coreexception_writing_html_file=CoreException writing html file: {0}
UseReportConverter_te_applying_xslt_skipped=Transformer exception applying XSLT to: not_searched.xml
UseReportConverter_no_additional_scan_info=No additional scan information is available.
UseReportConverter_no_xstl_specified=No XSLT file was specified.
-UseReportConverter_pce_error_getting_parser=ParserConfigurationException trying to get handle to the default parser.
UseReportConverter_preparing_html_root=Preparing HTML root...
UseReportConverter_preparing_report_metadata=Preparing Report Metadata...
UseReportConverter_preparing_xml_root=Preparing XML root...
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Signatures.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Signatures.java
index 573b211b910..065c9a83de9 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Signatures.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Signatures.java
@@ -795,8 +795,7 @@ static void collectSyntheticParam(final MethodDeclaration method, List r
}
continue;
}
- if (parent instanceof CompilationUnit) {
- CompilationUnit cunit = (CompilationUnit) parent;
+ if (parent instanceof CompilationUnit cunit) {
PackageDeclaration pdec = cunit.getPackage();
if (pdec != null) {
name.insert(0, '.');
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java
index 83c5e485ffe..b8ad37a1f89 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/util/Util.java
@@ -104,7 +104,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
import org.eclipse.jdt.internal.core.BinaryType;
import org.eclipse.jdt.internal.core.ClassFile;
import org.eclipse.jdt.internal.core.CompilationUnit;
@@ -140,7 +139,6 @@
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemTypes;
import org.eclipse.pde.api.tools.internal.search.SkippedComponent;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.objectweb.asm.Opcodes;
import org.osgi.framework.Version;
import org.w3c.dom.Document;
@@ -153,7 +151,6 @@
*
* @since 1.0.0
*/
-@SuppressWarnings("restriction")
public final class Util {
public static final String DOT_TGZ = ".tgz"; //$NON-NLS-1$
@@ -261,8 +258,7 @@ protected IStatus run(IProgressMonitor monitor) {
private void cancelBuild(Object jobfamily) {
Job[] buildJobs = Job.getJobManager().find(jobfamily);
for (Job curr : buildJobs) {
- if (curr != this && curr instanceof BuildJob) {
- BuildJob job = (BuildJob) curr;
+ if (curr != this && curr instanceof BuildJob job) {
if (job.isCoveredBy(this)) {
curr.cancel(); // cancel all other build jobs of our
// kind
@@ -1198,12 +1194,10 @@ public static IType updateType(String typeName, IJavaProject javaProject) throws
IPath path = IPath.fromOSString(typeNameWithSeparator);
IPath pathExceptLastSegment = path.removeLastSegments(1);
IJavaElement packFrag = javaProject.findElement(pathExceptLastSegment, DefaultWorkingCopyOwner.PRIMARY);
- if (packFrag instanceof PackageFragment) {
- PackageFragment pf = (PackageFragment) packFrag;
+ if (packFrag instanceof PackageFragment pf) {
List children = pf.getChildrenOfType(IJavaElement.COMPILATION_UNIT);
for (JavaElement object : children) {
- if (object instanceof CompilationUnit) {
- CompilationUnit compilationUn = (CompilationUnit) object;
+ if (object instanceof CompilationUnit compilationUn) {
ITypeRoot typeRoot = compilationUn.getTypeRoot();
if (typeRoot.findPrimaryType() == null) {
continue;
@@ -1216,8 +1210,7 @@ public static IType updateType(String typeName, IJavaProject javaProject) throws
}
List children2 = pf.getChildrenOfType(IJavaElement.CLASS_FILE);
for (JavaElement object : children2) {
- if (object instanceof ClassFile) {
- ClassFile compilationUn = (ClassFile) object;
+ if (object instanceof ClassFile compilationUn) {
ITypeRoot typeRoot = compilationUn.getTypeRoot();
if (typeRoot.findPrimaryType() == null) {
continue;
@@ -1251,8 +1244,7 @@ public static IType getTypeInSameJavaProject(IType type, String typeName, IJavaP
IJavaElement ancestor = type.getAncestor(IJavaElement.JAVA_PROJECT);
IType newType = null;
try {
- if (ancestor instanceof IJavaProject) {
- IJavaProject pro = (IJavaProject) ancestor;
+ if (ancestor instanceof IJavaProject pro) {
if (!pro.equals(javaProject)) {
newType = updateType(typeName, javaProject);
if (newType != null) {
@@ -1774,15 +1766,13 @@ public static boolean isBinaryProject(IProject project) {
* @return document
* @throws CoreException if unable to create a new document
*/
+ @SuppressWarnings("restriction")
public static Document newDocument() throws CoreException {
- DocumentBuilder docBuilder = null;
try {
- docBuilder = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ return org.eclipse.core.internal.runtime.XmlProcessorFactory.newDocumentWithErrorOnDOCTYPE();
} catch (ParserConfigurationException e) {
throw new CoreException(Status.error("Unable to create new XML document.", e)); //$NON-NLS-1$
}
- Document doc = docBuilder.newDocument();
- return doc;
}
/**
@@ -1794,25 +1784,15 @@ public static Document newDocument() throws CoreException {
* @throws CoreException if unable to parse the document
*/
public static Element parseDocument(String document) throws CoreException {
- Element root = null;
- InputStream stream = null;
- try {
- DocumentBuilder parser = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ try (InputStream stream = new ByteArrayInputStream(document.getBytes(StandardCharsets.UTF_8))) {
+ @SuppressWarnings("restriction")
+ DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createDocumentBuilderWithErrorOnDOCTYPE();
parser.setErrorHandler(new DefaultHandler());
- stream = new ByteArrayInputStream(document.getBytes(StandardCharsets.UTF_8));
- root = parser.parse(stream).getDocumentElement();
+ return parser.parse(stream).getDocumentElement();
} catch (ParserConfigurationException | FactoryConfigurationError | SAXException | IOException e) {
throw new CoreException(Status.error("Unable to parse XML document.", e)); //$NON-NLS-1$
- } finally {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- throw new CoreException(Status.error("Unable to parse XML document.", e)); //$NON-NLS-1$
- }
}
- return root;
}
/**
@@ -1888,7 +1868,9 @@ public static InputStream getInputStreamFromString(String string) {
public static String serializeDocument(Document document) throws CoreException {
try {
ByteArrayOutputStream s = new ByteArrayOutputStream();
- TransformerFactory factory = PDEXmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE();
+ @SuppressWarnings("restriction")
+ TransformerFactory factory = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createTransformerFactoryWithErrorOnDOCTYPE();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
@@ -2402,7 +2384,9 @@ public static String getApiElementType(int type) {
}
public static boolean isConstructor(String referenceMemberName) {
- return Arrays.equals(ConstantPool.Init, referenceMemberName.toCharArray());
+ @SuppressWarnings("restriction")
+ char[] init = org.eclipse.jdt.internal.compiler.codegen.ConstantPool.Init;
+ return Arrays.equals(init, referenceMemberName.toCharArray());
}
public static boolean isManifest(IPath path) {
@@ -2853,8 +2837,7 @@ public static IType findSourceTypeinJavaProject(IJavaProject javaProject, String
IType type = null;
try {
String pkgName = typeName.substring(0, typeName.lastIndexOf('.'));
- if (javaProject instanceof JavaProject) {
- JavaProject jp = (JavaProject) javaProject;
+ if (javaProject instanceof JavaProject jp) {
NameLookup newNameLookup = null;
try {
newNameLookup = jp.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
diff --git a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIDeprecationReportConversionTask.java b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIDeprecationReportConversionTask.java
index 11e74449e24..fb813361f31 100644
--- a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIDeprecationReportConversionTask.java
+++ b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIDeprecationReportConversionTask.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import org.apache.tools.ant.BuildException;
@@ -33,7 +32,6 @@
import org.eclipse.pde.api.tools.internal.IApiXmlConstants;
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -311,15 +309,7 @@ public void execute() throws BuildException {
System.out.println("xmlFileLocation : " + this.xmlFileLocation); //$NON-NLS-1$
System.out.println("htmlFileLocation : " + this.htmlFileLocation); //$NON-NLS-1$
}
- SAXParser parser = null;
- try {
- parser = PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
- } catch (ParserConfigurationException | SAXException e) {
- e.printStackTrace();
- }
- if (parser == null) {
- throw new BuildException(Messages.deprecationReportTask_couldNotCreateSAXParser);
- }
+ SAXParser parser = AnalysisReportConversionTask.createSAXParser();
File file = new File(this.xmlFileLocation);
if (this.htmlFileLocation == null) {
diff --git a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIFreezeReportConversionTask.java b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIFreezeReportConversionTask.java
index ee9500d9dcf..53c956c817a 100644
--- a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIFreezeReportConversionTask.java
+++ b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/APIFreezeReportConversionTask.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import org.apache.tools.ant.BuildException;
@@ -33,7 +32,6 @@
import org.eclipse.pde.api.tools.internal.IApiXmlConstants;
import org.eclipse.pde.api.tools.internal.provisional.comparator.IDelta;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -491,15 +489,7 @@ public void execute() throws BuildException {
}
}
}
- SAXParser parser = null;
- try {
- parser = PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
- } catch (ParserConfigurationException | SAXException e) {
- e.printStackTrace();
- }
- if (parser == null) {
- throw new BuildException(Messages.deltaReportTask_couldNotCreateSAXParser);
- }
+ SAXParser parser = AnalysisReportConversionTask.createSAXParser();
try {
ConverterDefaultHandler defaultHandler = new ConverterDefaultHandler(this.debug);
parser.parse(file, defaultHandler);
diff --git a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/AnalysisReportConversionTask.java b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/AnalysisReportConversionTask.java
index c78cedcd7e2..7ccee9bf70f 100644
--- a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/AnalysisReportConversionTask.java
+++ b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/AnalysisReportConversionTask.java
@@ -34,7 +34,6 @@
import org.eclipse.pde.api.tools.internal.IApiXmlConstants;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.util.Util;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -429,15 +428,7 @@ public void execute() throws BuildException {
if (!this.reportsRoot.exists() || !this.reportsRoot.isDirectory()) {
throw new BuildException(NLS.bind(Messages.invalid_directory_name, this.xmlReportsLocation));
}
- SAXParser parser = null;
- try {
- parser = PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
- } catch (ParserConfigurationException | SAXException e) {
- e.printStackTrace();
- }
- if (parser == null) {
- throw new BuildException(Messages.could_not_create_sax_parser);
- }
+ SAXParser parser = createSAXParser();
if (this.htmlReportsLocation == null) {
this.htmlReportsLocation = this.xmlReportsLocation;
@@ -490,6 +481,15 @@ public void execute() throws BuildException {
}
}
+ @SuppressWarnings("restriction")
+ static SAXParser createSAXParser() {
+ try {
+ return org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
+ } catch (ParserConfigurationException | SAXException e) {
+ throw new BuildException(Messages.could_not_create_sax_parser, e);
+ }
+ }
+
private String extractLinkFrom(String fileName) {
StringBuilder buffer = new StringBuilder();
buffer.append('.').append(fileName.substring(this.htmlRoot.getAbsolutePath().length()).replace('\\', '/'));
diff --git a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java
index 55d8a7b6f46..4b6a41b7962 100644
--- a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java
+++ b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/Messages.java
@@ -29,7 +29,6 @@ public class Messages extends NLS {
public static String deltaReportTask_entry_major_version;
public static String deltaReportTask_entry_minor_version;
public static String deltaReportTask_missingXmlFileLocation;
- public static String deltaReportTask_couldNotCreateSAXParser;
public static String deltaReportTask_xmlFileLocationShouldHaveAnXMLExtension;
public static String deltaReportTask_htmlFileLocationShouldHaveAnHtmlExtension;
public static String deltaReportTask_missingXmlFile;
@@ -118,7 +117,6 @@ public class Messages extends NLS {
public static String ChangedElement;
public static String deprecationReportTask_componentEntry;
- public static String deprecationReportTask_couldNotCreateSAXParser;
public static String deprecationReportTask_endComponentEntry;
public static String deprecationReportTask_entry;
public static String deprecationReportTask_footer;
diff --git a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties
index 215e6409c74..318a3ba60f5 100644
--- a/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties
+++ b/apitools/org.eclipse.pde.api.tools/src_ant/org/eclipse/pde/api/tools/internal/tasks/messages.properties
@@ -41,7 +41,6 @@ deltaReportTask_missingXmlFileLocation=Missing the xml file location argument
deltaReportTask_missingXmlFile=The xml report file {0} does not exist
deltaReportTask_xmlFileLocationMustBeAFile=The xml report file {0} must be a file and not a directory
deltaReportTask_hmlFileLocationMustBeAFile=The html report file {0} must be a file and not a directory
-deltaReportTask_couldNotCreateSAXParser=Could not create a sax parser
missing_xml_files_location=The directory that contains xml reports must be specified
invalid_directory_name=''{0}'' is not a valid directory name
could_not_create_sax_parser=Could not create a sax parser
@@ -204,7 +203,6 @@ RemovedElement=REMOVED
ChangedElement=CHANGED
deprecationReportTask_componentEntry=\n\
\ \n {0} | \n
\n
-deprecationReportTask_couldNotCreateSAXParser=Could not create a sax parser
deprecationReportTask_endComponentEntry=
\n
deprecationReportTask_entry=\ \n {0} | {1} | \n
\n
deprecationReportTask_header=\n\
diff --git a/apitools/pom.xml b/apitools/pom.xml
index 809b40dfa99..bbf038266b6 100644
--- a/apitools/pom.xml
+++ b/apitools/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
eclipse.pde.apitools
pom
diff --git a/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF b/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
index 26bd5700e55..6654dbba458 100644
--- a/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.pde.build.tests/META-INF/MANIFEST.MF
@@ -9,7 +9,6 @@ Export-Package: org.eclipse.pde.build.internal.tests;x-internal:=true,
org.eclipse.pde.build.internal.tests.p2;x-internal:=true,
org.eclipse.pde.build.tests
Require-Bundle: org.eclipse.core.runtime,
- org.junit,
org.eclipse.pde.build,
org.eclipse.ant.core,
org.apache.ant,
@@ -29,7 +28,10 @@ Import-Package: org.eclipse.equinox.frameworkadmin;version="2.0.0",
org.eclipse.equinox.p2.repository;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.metadata;version="[2.0.0,3.0.0)",
- org.eclipse.equinox.simpleconfigurator.manipulator;version="2.0.0"
+ org.eclipse.equinox.simpleconfigurator.manipulator;version="2.0.0",
+ org.junit,
+ org.junit.runner,
+ org.junit.runners
Bundle-ActivationPolicy: lazy
Eclipse-BundleShape: dir
Automatic-Module-Name: org.eclipse.pde.build.tests
diff --git a/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java b/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java
index ad4468b34f2..a682635acd1 100644
--- a/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java
+++ b/build/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2021 IBM Corporation and others.
+ * Copyright (c) 2004, 2023 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Hannes Wellmann - Enhance computation of system-package provided by a ExecutionEnvironment
*******************************************************************************/
package org.eclipse.pde.internal.build.site;
@@ -21,6 +22,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Comparator;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
@@ -28,10 +30,14 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
+import java.util.function.UnaryOperator;
import java.util.jar.JarFile;
+import java.util.regex.Pattern;
+import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -44,6 +50,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.LibraryLocation;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
@@ -67,6 +74,7 @@
// This class provides a higher level API on the state
public class PDEState implements IPDEBuildConstants, IBuildPropertiesConstants {
+ private static final ILog LOGGER = ILog.get();
private static final String[] MANIFEST_ENTRIES = {Constants.BUNDLE_LOCALIZATION, Constants.BUNDLE_NAME, Constants.BUNDLE_VENDOR, ECLIPSE_BUNDLE_SHAPE, ECLIPSE_SOURCE_BUNDLE, ECLIPSE_SOURCE_REF};
private static final int LAST_SUPPORTED_JDK = Integer.parseInt(JavaCore.latestSupportedJavaVersion());
private StateObjectFactory factory;
@@ -388,7 +396,6 @@ public void resolveState() {
// initialize profileManager and get the JRE profiles
String[] javaProfiles = getJavaProfiles();
- String systemPackages = null;
String ee = null;
for (Config aConfig : configs) {
@@ -435,7 +442,8 @@ public void resolveState() {
if (profileProps != null) {
String profileName = profileProps.getProperty(ProfileManager.PROFILE_NAME);
if (AbstractScriptGenerator.getImmutableAntProperty(profileName) != null || (j == 0 && !added)) {
- systemPackages = profileProps.getProperty(ProfileManager.SYSTEM_PACKAGES);
+ IExecutionEnvironment env = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(javaProfiles[j]);
+ String systemPackages = getSystemPackages(env, profileProps);
ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
prop = new Hashtable<>();
@@ -459,7 +467,7 @@ public void resolveState() {
for (String execEnvID : eeJava10AndBeyond) {
prop = new Hashtable<>();
IExecutionEnvironment env = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(execEnvID);
- systemPackages = querySystemPackages(env);
+ String systemPackages = getSystemPackages(env, null);
String currentEE = previousEE + "," + execEnvID; //$NON-NLS-1$
if (systemPackages == null) {
previousEE = currentEE;
@@ -480,13 +488,186 @@ public void resolveState() {
}
}
- public static String querySystemPackages(IExecutionEnvironment environment) {
- // Copy of org.eclipse.pde.internal.core.TargetPlatformHelper.querySystemPackages()
- IVMInstall vm = bestVmInstallFor(environment);
- if (vm == null || !JavaRuntime.isModularJava(vm)) {
+ public static String getSystemPackages(IExecutionEnvironment environment, Properties profileProperties) {
+ // The pre-defined lists of system-packages are incomplete. Always overwrite, if we have a more up-to-date one.
+ String systemPackages = querySystemPackages(environment, profileProperties);
+ if (systemPackages.isBlank() && profileProperties != null) {
+ // Unable to compute system-packages, probably OSGi specific EE. Use exactly the packages specified in its profile
+ systemPackages = profileProperties.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
+ }
+ if (systemPackages == null || systemPackages.isBlank()) {
+ if (compatibleVMsFor(environment, s -> s).findAny().isPresent()) {
+ LOGGER.warn("No JVM system-packages available for environment " + environment); //$NON-NLS-1$
+ }
return null;
}
- String release = environment.getProfileProperties().getProperty(JavaCore.COMPILER_COMPLIANCE);
+ return systemPackages;
+ }
+
+ private static final Pattern COMMA = Pattern.compile(","); //$NON-NLS-1$
+
+ public static String querySystemPackages(IExecutionEnvironment environment, Properties preJava9ProfileProperties) {
+ if (environment == null) {
+ return ""; //$NON-NLS-1$
+ }
+ String eeId = environment.getId();
+ Integer releaseVersion = readJavaReleaseVersion(eeId);
+ if (releaseVersion == null) {
+ return ""; //$NON-NLS-1$
+ }
+ Collection systemPackages;
+ if (releaseVersion <= 8) {
+ var strictVMSystemPackages = compatibleVMsFor(environment, vms -> vms.filter(environment::isStrictlyCompatible)) // Use only selected VM or perfect matches
+ .map(vm -> querySystemPackages(vm, null)) // In case a VM is selected for an EE, query that VM and use its system-packages
+ .filter(Objects::nonNull).findFirst();
+ systemPackages = strictVMSystemPackages.orElseGet(() -> {
+ // No VM selected for the non-modular EE:
+ // Compose list of available system-packages from the java.* packages in the predefined profiles in o.e.osgi respectively the hard-coded lists of java-packages in this class
+ // plus the non-java packages of this workspace's default VM.
+ // The reasoning for this is, that the OSGi standard only requires the java.* packages of an EE to be present, everything else is optional.
+ // Therefore the Workspaces default VM (which can also be set as target VM in the active target-definition) is the best guess for them.
+ // See also OSGi 8.0 specification chapter 3.4 Execution Environment
+
+ List javaPackages = PRE_JAVA_9_SYSTEM_PACKAGES.get(eeId);
+ if (javaPackages == null) {
+ String profileSystemPackages = preJava9ProfileProperties.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES, ""); //$NON-NLS-1$
+ if (profileSystemPackages.isBlank()) {
+ return List.of();
+ }
+ javaPackages = COMMA.splitAsStream(profileSystemPackages).filter(p -> p.startsWith("java.")).toList(); //$NON-NLS-1$
+ }
+ IVMInstall targetVM = JavaRuntime.getDefaultVMInstall(); // Set by the Target-Definition if specified there
+ if (targetVM == null) {
+ LOGGER.warn("No default JRE installation selected"); //$NON-NLS-1$
+ return List.of();
+ }
+ Collection targetVMSystemPackages = querySystemPackages(targetVM, null);
+ if (targetVMSystemPackages == null) {
+ return List.of();
+ }
+ Stream targetVMNonJavaPackages = targetVMSystemPackages.stream().filter(p -> !p.startsWith("java.")); //$NON-NLS-1$
+
+ return Stream.concat(javaPackages.stream(), targetVMNonJavaPackages).sorted().toList();
+ });
+ } else {
+ Comparator strictlyCompatibleFirst = Comparator.comparing(environment::isStrictlyCompatible).reversed(); // false vms.sorted(strictlyCompatibleFirst)) // Query strictly compatible first
+ .map(vm -> querySystemPackages(vm, environment)) //
+ .filter(Objects::nonNull).findFirst().orElse(List.of());
+ }
+ return String.join(",", systemPackages); //$NON-NLS-1$
+ }
+
+ @SuppressWarnings("nls")
+ private static Integer readJavaReleaseVersion(String eeId) {
+ if (eeId.startsWith("JavaSE-")) { //$NON-NLS-1$
+ try {
+ return Integer.parseInt(eeId.substring("JavaSE-".length())); //$NON-NLS-1$
+ } catch (NumberFormatException e) { // Another EE
+ }
+ }
+ return switch (eeId) {
+ // There is no EE for Java 1.0 in OSGi
+ case "JRE-1.1" -> 1;
+ case "J2SE-1.2" -> 2;
+ case "J2SE-1.3" -> 3;
+ case "J2SE-1.4" -> 4;
+ case "J2SE-1.5" -> 5;
+ case "JavaSE-1.6" -> 6;
+ case "JavaSE-1.7" -> 7;
+ case "JavaSE-1.8" -> 8;
+ default -> null;
+ };
+ }
+
+ // Old JDKs can for example be obtained from https://www.oracle.com/java/technologies/downloads/archive/
+ @SuppressWarnings("nls")
+ private static final Map> PRE_JAVA_9_SYSTEM_PACKAGES = Map.of(//
+ "JRE-1.1", List.of("java.applet", //
+ "java.awt", //
+ "java.awt.datatransfer", //
+ "java.awt.event", //
+ "java.awt.image", //
+ "java.awt.peer", //
+ "java.beans", //
+ "java.io", //
+ "java.lang", //
+ "java.lang.reflect", //
+ "java.math", //
+ "java.net", //
+ "java.rmi", //
+ "java.rmi.dgc", //
+ "java.rmi.registry", //
+ "java.rmi.server", //
+ "java.security", //
+ "java.security.acl", //
+ "java.security.interfaces", //
+ "java.sql", //
+ "java.text", //
+ "java.text.resources", //
+ "java.util", //
+ "java.util.zip"),
+ "J2SE-1.2", List.of("java.applet", //
+ "java.awt", //
+ "java.awt.color", //
+ "java.awt.datatransfer", //
+ "java.awt.dnd", //
+ "java.awt.dnd.peer", //
+ "java.awt.event", //
+ "java.awt.font", //
+ "java.awt.geom", //
+ "java.awt.im", //
+ "java.awt.image", //
+ "java.awt.image.renderable", //
+ "java.awt.peer", //
+ "java.awt.print", //
+ "java.awt.resources", //
+ "java.beans", //
+ "java.beans.beancontext", //
+ "java.io", //
+ "java.lang", //
+ "java.lang.ref", //
+ "java.lang.reflect", //
+ "java.math", //
+ "java.net", //
+ "java.rmi", //
+ "java.rmi.activation", //
+ "java.rmi.dgc", //
+ "java.rmi.registry", //
+ "java.rmi.server", //
+ "java.security", //
+ "java.security.acl", //
+ "java.security.cert", //
+ "java.security.interfaces", //
+ "java.security.spec", //
+ "java.sql", //
+ "java.text", //
+ "java.text.resources", //
+ "java.util", //
+ "java.util.jar", //
+ "java.util.zip"));
+
+ private static Collection querySystemPackages(IVMInstall vm, IExecutionEnvironment environment) {
+ if (!JavaRuntime.isModularJava(vm)) {
+ Set classFileDirectories = new HashSet<>();
+ for (LibraryLocation libLocation : JavaRuntime.getLibraryLocations(vm)) {
+ IPath path = libLocation.getSystemLibraryPath();
+ if (path != null) {
+ try (ZipFile zip = new ZipFile(path.toFile())) {
+ // Collect names of all directories that contain a .class file
+ zip.stream().filter(e -> !e.isDirectory()).map(ZipEntry::getName) //
+ .filter(n -> n.endsWith(".class") && n.indexOf('/') > 0) //$NON-NLS-1$
+ .map(n -> n.substring(0, n.lastIndexOf('/'))) //
+ .forEach(classFileDirectories::add);
+ } catch (Exception e) {
+ LOGGER.error("Failed to read packages in JVM library for " + vm + ", at " + path, e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ return classFileDirectories.stream().map(n -> n.replace('/', '.')).sorted().toList();
+ }
+
+ String release = environment != null ? environment.getProfileProperties().getProperty(JavaCore.COMPILER_COMPLIANCE) : null;
try {
Collection packages = new TreeSet<>();
String jrtPath = "lib/" + org.eclipse.jdt.internal.compiler.util.JRTUtil.JRT_FS_JAR; //$NON-NLS-1$
@@ -503,31 +684,19 @@ public static String querySystemPackages(IExecutionEnvironment environment) {
}
}
}
- return String.join(",", packages); //$NON-NLS-1$
+ return packages;
} catch (CoreException e) {
- ILog.of(PDEState.class).log(Status.error("failed to read system packages for " + environment, e)); //$NON-NLS-1$
+ ILog.of(PDEState.class).log(Status.error("Failed to read system packages for " + environment, e)); //$NON-NLS-1$
}
return null;
}
- private static IVMInstall bestVmInstallFor(IExecutionEnvironment environment) {
- if (environment == null) {
- return null;
- }
+ private static Stream compatibleVMsFor(IExecutionEnvironment environment, UnaryOperator> vmInstallsFilter) {
IVMInstall defaultVM = environment.getDefaultVM();
if (defaultVM != null) {
- return defaultVM;
- }
- IVMInstall[] compatible = environment.getCompatibleVMs();
- if (compatible.length == 0) {
- return null;
- }
- for (IVMInstall vm : compatible) {
- if (environment.isStrictlyCompatible(vm)) {
- return vm;
- }
+ return Stream.of(defaultVM); // User selected a VM for the EE, only consider that
}
- return compatible[0];
+ return vmInstallsFilter.apply(Arrays.stream(environment.getCompatibleVMs()));
}
public State getState() {
diff --git a/build/pom.xml b/build/pom.xml
index 9c436394586..ee217ec842e 100644
--- a/build/pom.xml
+++ b/build/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
eclipse.pde.build
pom
diff --git a/ds/org.eclipse.pde.ds.annotations.tests/META-INF/MANIFEST.MF b/ds/org.eclipse.pde.ds.annotations.tests/META-INF/MANIFEST.MF
index 96cb302227d..2a13c04f098 100644
--- a/ds/org.eclipse.pde.ds.annotations.tests/META-INF/MANIFEST.MF
+++ b/ds/org.eclipse.pde.ds.annotations.tests/META-INF/MANIFEST.MF
@@ -10,11 +10,13 @@ Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.pde.ds.annotations;bundle-version="[1.1.0,1.4.0)",
org.eclipse.pde.ds.core;bundle-version="[1.1.0,2.0.0)",
org.eclipse.pde.ui;bundle-version="[3.9.0,4.0.0)",
- org.junit;bundle-version="[4.12.0,5.0.0)",
org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.text;bundle-version="[3.6.0,4.0.0)"
Export-Package: org.eclipse.pde.ds.internal.annotations.tests;x-internal:=true
+Import-Package: org.junit,
+ org.junit.runner,
+ org.junit.runners
Eclipse-BundleShape: dir
Bundle-ClassPath: tests.jar
Automatic-Module-Name: org.eclipse.pde.ds.annotations.tests
diff --git a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSBuilder.java b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSBuilder.java
index 2d69d1cb481..a1ba2f0f784 100644
--- a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSBuilder.java
+++ b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSBuilder.java
@@ -33,6 +33,7 @@
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.internal.core.builders.DefaultSAXParser;
import org.eclipse.pde.internal.core.builders.PDEBuilderHelper;
import org.eclipse.pde.internal.ds.core.Activator;
import org.eclipse.pde.internal.ds.core.Messages;
@@ -130,7 +131,7 @@ protected IProject[] build(int kind, Map args, IProgressMonitor
@Override
protected void clean(IProgressMonitor monitor) throws CoreException {
// bug 426874 - delete markers set and files created
- getProject().deleteMarkers(DSMarkerFactory.MARKER_ID, true, IResource.DEPTH_INFINITE);
+ getProject().deleteMarkers(DSErrorReporter.MARKER_ID, true, IResource.DEPTH_INFINITE);
}
diff --git a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSErrorReporter.java b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSErrorReporter.java
index c9b781141b0..f72a7b2ec78 100644
--- a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSErrorReporter.java
+++ b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSErrorReporter.java
@@ -27,6 +27,8 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.text.Document;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
+import org.eclipse.pde.internal.core.builders.XMLErrorReporter;
import org.eclipse.pde.internal.core.text.IDocumentElementNode;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.eclipse.pde.internal.ds.core.Activator;
@@ -47,16 +49,17 @@
import org.w3c.dom.NodeList;
public class DSErrorReporter extends XMLErrorReporter {
+ public static final String MARKER_ID = "org.eclipse.pde.ds.core.problem"; //$NON-NLS-1$
public static final int ERROR = 0;
public static final int WARNING = 1;
public static final int IGNORE = 2;
public DSErrorReporter(IFile file) {
- super(file);
+ super(file, MARKER_ID);
}
@Override
- public void validateContent(IProgressMonitor monitor) {
+ public void validate(IProgressMonitor monitor) {
try {
Document textDocument = CoreUtility.getTextDocument(fFile
@@ -93,7 +96,7 @@ private void reportIllegalAttributeValue(Element element, Attr attr) {
String message = NLS.bind(Messages.DSErrorReporter_attrValue, attr
.getValue(), attr.getName());
report(message, getLine(element, attr.getName()), ERROR,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
private void validateReferenceElements(IDSReference[] references) {
@@ -147,7 +150,7 @@ private void reportInvalidTarget(Element element, String target) {
.getAttribute(IDSConstants.ATTRIBUTE_REFERENCE_NAME);
String message = NLS.bind(Messages.DSErrorReporter_invalidTarget, name,
target);
- report(message, getLine(element), ERROR, DSMarkerFactory.CAT_OTHER);
+ report(message, getLine(element), ERROR, PDEMarkerFactory.CAT_OTHER);
}
private void validateReferenceElementNames(Hashtable referencedNames,
@@ -171,7 +174,7 @@ private void reportDuplicateReferenceElementName(Element element,
Messages.DSErrorReporter_duplicateReferenceName, name);
report(message,
getLine(element, IDSConstants.ATTRIBUTE_REFERENCE_NAME), ERROR,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
private void validateReferencePolicy(Element element) {
@@ -203,7 +206,7 @@ private void reportIllegalPolicy(Element element, String policy) {
Attr attr = element
.getAttributeNode(IDSConstants.ATTRIBUTE_REFERENCE_POLICY);
report(message, getLine(element, attr.getName()), ERROR,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
private void validateReferenceCardinality(Element element) {
@@ -242,7 +245,7 @@ private void reportIllegalCardinality(Element element, String cardinality) {
if (attr == null || attr.getValue() == null || attr.getName() == null)
return;
report(message, getLine(element, attr.getName()), ERROR,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
private void validatePropertiesElements(IDSProperties[] propertiesElements) {
@@ -261,7 +264,7 @@ private void validatePropertiesElements(IDSProperties[] propertiesElements) {
.bind(
Messages.DSErrorReporter_cannotFindProperties,
properties.getEntry()), getLine(element), WARNING,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
}
@@ -368,7 +371,7 @@ private void reportPropertyTypeCastException(Element element, String value,
String message = NLS.bind(
Messages.DSErrorReporter_propertyTypeCastException,
new String[] { value, type });
- report(message, getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
+ report(message, getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}
/**
@@ -409,7 +412,7 @@ private void validatePropertyAttrValueAndBody(Element element,
private void reportEmptyPropertyValue(Element element, String propertyName) {
String message = NLS.bind(Messages.DSErrorReporter_emptyPropertyValue,
propertyName);
- report(message, getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
+ report(message, getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}
@@ -418,7 +421,7 @@ private void reportSingleAndMultiplePropertyValues(Element element,
String message = NLS.bind(
Messages.DSErrorReporter_singleAndMultipleAttrValue,
propertyName, value);
- report(message, getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
+ report(message, getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}
private void validatePropertyTypes(Element element) {
@@ -485,7 +488,7 @@ private void reportMissingRequiredAttribute(Element element,
String attName, int severity) {
String message = NLS.bind(Messages.DSErrorReporter_requiredAttribute,
attName, element.getNodeName());
- report(message, getLine(element), severity, DSMarkerFactory.CAT_OTHER);
+ report(message, getLine(element), severity, PDEMarkerFactory.CAT_OTHER);
}
/**
@@ -507,7 +510,7 @@ private void reportJavaTypeNotFound(String elementConstant,
Element element = (Element) elementsByTagName.item(index);
report(NLS.bind(Messages.DSErrorReporter_cannotFindJavaType, resource,
attributeConstant), getLine(element), WARNING,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
private void validateComponentElement(IDSComponent component) {
@@ -518,7 +521,7 @@ private void validateComponentElement(IDSComponent component) {
report(NLS.bind(Messages.DSErrorReporter_requiredElement,
IDSConstants.ELEMENT_IMPLEMENTATION),
getLine(getDocumentRoot()), ERROR,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
// validate boolean values
@@ -556,7 +559,7 @@ private void validateConfigurationPolicyAttribute(Element element,
report(
Messages.DSErrorReporter_invalidConfigurationPolicyValue,
getLine(element), WARNING,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
}
}
@@ -589,13 +592,13 @@ private void validateImmediateAttribute(Element element,
private void reportInvalidImmediateFactory(Element element) {
report(Messages.DSErrorReporter_invalidImmediateValueFactory,
- getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
+ getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}
private void reportInvalidImmediate(Element element) {
report(Messages.DSErrorReporter_invalidImmediateValue,
- getLine(element), WARNING, DSMarkerFactory.CAT_OTHER);
+ getLine(element), WARNING, PDEMarkerFactory.CAT_OTHER);
}
private void validateEmpty(Element element, Attr attr) {
@@ -612,7 +615,7 @@ private void reportIllegalEmptyAttributeValue(Element element, Attr attr) {
String message = NLS.bind(Messages.DSErrorReporter_emptyAttrValue, attr
.getName());
report(message, getLine(element, attr.getName()), ERROR,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
}
private void validateServiceElement(IDSService service) {
@@ -635,7 +638,7 @@ private void validateServiceElement(IDSService service) {
private void reportEmptyService(Element element) {
report(Messages.DSErrorReporter_illegalEmptyService, getLine(element),
- ERROR, DSMarkerFactory.CAT_OTHER);
+ ERROR, PDEMarkerFactory.CAT_OTHER);
}
private void validateServiceFactory(Element element, IDSService service) {
@@ -658,14 +661,14 @@ private void validateServiceFactory(Element element, IDSService service) {
private void reportIllegalServiceFactory_Immediate(Element element) {
report(Messages.DSErrorReporter_illegalServiceFactory_Immediate,
- getLine(element), ERROR, DSMarkerFactory.CAT_OTHER);
+ getLine(element), ERROR, PDEMarkerFactory.CAT_OTHER);
}
private void reportIllegalServiceFactory(Element element) {
report(Messages.DSErrorReporter_illegalServiceFactory,
- getLine(element), ERROR, DSMarkerFactory.CAT_OTHER);
+ getLine(element), ERROR, PDEMarkerFactory.CAT_OTHER);
}
private void validateProvideElement(IDSProvide[] providedServices) {
@@ -702,7 +705,7 @@ private void validateDuplicateInterface(Hashtable providedInterf
String message = NLS.bind(
Messages.DSErrorReporter_duplicatedInterface, interface1);
report(message, getLine(element), WARNING,
- DSMarkerFactory.CAT_OTHER);
+ PDEMarkerFactory.CAT_OTHER);
} else {
providedInterfaces.put(interface1, interface1);
}
diff --git a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSMarkerFactory.java b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSMarkerFactory.java
deleted file mode 100644
index 16919d6d755..00000000000
--- a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DSMarkerFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Rafael Oliveira Nóbrega - bug 230232
- *******************************************************************************/
-package org.eclipse.pde.internal.ds.core.builders;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-
-public class DSMarkerFactory {
-
- public static final String MARKER_ID = "org.eclipse.pde.ds.core.problem"; //$NON-NLS-1$
- public static final int NO_RESOLUTION = -1;
-
- public static final String CAT_OTHER = ""; //$NON-NLS-1$
-
- /**
- * @param file
- * @return
- * @throws CoreException
- */
- public IMarker createMarker(IFile file) throws CoreException {
- return createMarker(file, NO_RESOLUTION, ""); //$NON-NLS-1$
- }
-
- public IMarker createMarker(IFile file, int id, String category)
- throws CoreException {
- IMarker marker = file.createMarker(MARKER_ID);
- marker.setAttribute("id", id); //$NON-NLS-1$
- marker.setAttribute("categoryId", category); //$NON-NLS-1$
- return marker;
- }
-
-}
diff --git a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DefaultSAXParser.java b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DefaultSAXParser.java
deleted file mode 100644
index 771994f7dd5..00000000000
--- a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/DefaultSAXParser.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Rafael Oliveira Nóbrega - bug 230232
- *******************************************************************************/
-
-package org.eclipse.pde.internal.ds.core.builders;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.pde.internal.core.util.SAXParserWrapper;
-import org.xml.sax.SAXException;
-
-public class DefaultSAXParser {
-
- public static void parse(IFile file, XMLErrorReporter reporter) {
- try (InputStream stream = new BufferedInputStream(file.getContents())) {
- SAXParserWrapper.parse(stream, reporter);
- } catch (CoreException | SAXException | IOException | ParserConfigurationException e) {
- }
- }
-}
diff --git a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/XMLErrorReporter.java b/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/XMLErrorReporter.java
deleted file mode 100644
index 4a26b0b8793..00000000000
--- a/ds/org.eclipse.pde.ds.core/src/org/eclipse/pde/internal/ds/core/builders/XMLErrorReporter.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2015 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.ds.core.builders;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Stack;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.pde.internal.core.builders.CompilerFlags;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class XMLErrorReporter extends DefaultHandler {
-
- public static final char F_ATT_PREFIX = '@';
- public static final char F_ATT_VALUE_PREFIX = '!';
- public static final char F_CHILD_SEP = '>';
-
- static class ElementData {
- int offset;
- boolean fErrorNode;
-
- public ElementData(int offset) {
- this.offset = offset;
- }
- }
-
- protected IFile fFile;
- protected IProject fProject;
- private int fErrorCount;
- private DSMarkerFactory fMarkerFactory;
- private org.w3c.dom.Document fXMLDocument;
- private IDocument fTextDocument;
- private Stack fElementStack;
- private Element fRootElement;
- private Locator fLocator;
- private int fHighestOffset;
- private HashMap fOffsetTable;
- private FindReplaceDocumentAdapter fFindReplaceAdapter;
-
- public XMLErrorReporter(IFile file) {
- ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
- try {
- fFile = file;
- fProject = file.getProject();
- manager.connect(file.getFullPath(), LocationKind.NORMALIZE, null);
- fTextDocument = manager.getTextFileBuffer(file.getFullPath(), LocationKind.NORMALIZE).getDocument();
- manager.disconnect(file.getFullPath(), LocationKind.NORMALIZE, null);
- fFindReplaceAdapter = new FindReplaceDocumentAdapter(fTextDocument);
- fOffsetTable = new HashMap<>();
- fElementStack = new Stack<>();
- removeFileMarkers();
- } catch (CoreException e) {
- // TODO log message
- }
- }
-
- public IFile getFile() {
- return fFile;
- }
-
- private IMarker addMarker(String message, int lineNumber, int severity, int fixId, String category) {
- try {
- IMarker marker = getMarkerFactory().createMarker(fFile, fixId, category);
- marker.setAttribute(IMarker.MESSAGE, message);
- marker.setAttribute(IMarker.SEVERITY, severity);
- if (lineNumber == -1)
- lineNumber = 1;
- marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
- if (severity == IMarker.SEVERITY_ERROR)
- fErrorCount += 1;
- return marker;
- } catch (CoreException e) {
- // TODO log something
- }
- return null;
- }
-
- private DSMarkerFactory getMarkerFactory() {
- if (fMarkerFactory == null)
- fMarkerFactory = new DSMarkerFactory();
- return fMarkerFactory;
- }
-
- private void addMarker(SAXParseException e, int severity) {
- addMarker(e.getMessage(), e.getLineNumber(), severity,
- DSMarkerFactory.NO_RESOLUTION, DSMarkerFactory.CAT_OTHER);
- }
-
- @Override
- public void error(SAXParseException exception) throws SAXException {
- addMarker(exception, IMarker.SEVERITY_ERROR);
- generateErrorElementHierarchy();
- }
-
- @Override
- public void fatalError(SAXParseException exception) throws SAXException {
- addMarker(exception, IMarker.SEVERITY_ERROR);
- generateErrorElementHierarchy();
- }
-
- public int getErrorCount() {
- return fErrorCount;
- }
-
- private void removeFileMarkers() {
- try {
- fFile.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
- fFile.deleteMarkers(DSMarkerFactory.MARKER_ID, false, IResource.DEPTH_ZERO);
- } catch (CoreException e) {
- // TODO log exception
- }
- }
-
-
- public IMarker report(String message, int line, int severity, int fixId, String category) {
- if (severity == CompilerFlags.ERROR)
- return addMarker(message, line, IMarker.SEVERITY_ERROR, fixId, category);
- if (severity == CompilerFlags.WARNING)
- return addMarker(message, line, IMarker.SEVERITY_WARNING, fixId, category);
- return null;
- }
-
- public IMarker report(String message, int line, int severity, String category) {
- return report(message, line, severity, DSMarkerFactory.NO_RESOLUTION,
- category);
- }
-
- @Override
- public void warning(SAXParseException exception) throws SAXException {
- addMarker(exception, IMarker.SEVERITY_WARNING);
- }
-
- @Override
- public void startDocument() throws SAXException {
- try {
- // TODO we should be using a dom level 2 impl
- fXMLDocument = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE().newDocument();
- } catch (ParserConfigurationException e) {
- }
- }
-
- @Override
- public void endDocument() throws SAXException {
- fXMLDocument.appendChild(fRootElement);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- Element element = fXMLDocument.createElement(qName);
- for (int i = 0; i < attributes.getLength(); i++) {
- element.setAttribute(attributes.getQName(i), attributes.getValue(i));
- }
-
- if (fRootElement == null)
- fRootElement = element;
- else
- fElementStack.peek().appendChild(element);
- fElementStack.push(element);
- try {
- if (fTextDocument != null)
- fOffsetTable.put(element, new ElementData(getStartOffset(qName)));
- } catch (BadLocationException e) {
- }
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- fElementStack.pop();
- }
-
- private void generateErrorElementHierarchy() {
- while (!fElementStack.isEmpty()) {
- ElementData data = fOffsetTable.get(fElementStack.pop());
- if (data != null)
- data.fErrorNode = true;
- }
- }
-
- @Override
- public void characters(char[] characters, int start, int length) throws SAXException {
- StringBuilder buff = new StringBuilder();
- for (int i = 0; i < length; i++) {
- buff.append(characters[start + i]);
- }
- Text text = fXMLDocument.createTextNode(buff.toString());
- if (fRootElement == null)
- fXMLDocument.appendChild(text);
- else
- fElementStack.peek().appendChild(text);
- }
-
- @Override
- public void setDocumentLocator(Locator locator) {
- fLocator = locator;
- }
-
- private int getStartOffset(String elementName) throws BadLocationException {
- int line = fLocator.getLineNumber();
- int col = fLocator.getColumnNumber();
- if (col < 0)
- col = fTextDocument.getLineLength(line);
- String text = fTextDocument.get(fHighestOffset + 1, fTextDocument.getLineOffset(line) - fHighestOffset - 1);
-
- ArrayList commentPositions = new ArrayList<>();
- for (int idx = 0; idx < text.length();) {
- idx = text.indexOf("", idx); //$NON-NLS-1$
- if (end == -1)
- break;
-
- commentPositions.add(new Position(idx, end - idx));
- idx = end + 1;
- }
-
- int idx = 0;
- for (; idx < text.length(); idx += 1) {
- idx = text.indexOf("<" + elementName, idx); //$NON-NLS-1$
- if (idx == -1)
- break;
- boolean valid = true;
- for (int i = 0; i < commentPositions.size(); i++) {
- Position pos = commentPositions.get(i);
- if (pos.includes(idx)) {
- valid = false;
- break;
- }
- }
- if (valid)
- break;
- }
- if (idx > -1)
- fHighestOffset += idx + 1;
- return fHighestOffset;
- }
-
- private int getAttributeOffset(String name, String value, int offset) throws BadLocationException {
- IRegion nameRegion = fFindReplaceAdapter.find(offset, name + "=\"" + getWritableString(value), true, false, false, false); //$NON-NLS-1$
- if (nameRegion != null) {
- return nameRegion.getOffset();
- }
- return -1;
- }
-
- private String getWritableString(String source) {
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < source.length(); i++) {
- char c = source.charAt(i);
- switch (c) {
- case '&' :
- buf.append("&"); //$NON-NLS-1$
- break;
- case '<' :
- buf.append("<"); //$NON-NLS-1$
- break;
- case '>' :
- buf.append(">"); //$NON-NLS-1$
- break;
- case '\'' :
- buf.append("'"); //$NON-NLS-1$
- break;
- case '\"' :
- buf.append("""); //$NON-NLS-1$
- break;
- default :
- buf.append(c);
- break;
- }
- }
- return buf.toString();
- }
-
- protected String getTextContent(Element element) {
- ElementData data = fOffsetTable.get(element);
- try {
- IRegion nameRegion = fFindReplaceAdapter.find(data.offset, "" + element.getNodeName() + ">", true, true, false, false); //$NON-NLS-1$ //$NON-NLS-2$
- int offset = data.offset + element.getNodeName().length() + 2;
- if (nameRegion != null)
- return fTextDocument.get(offset, nameRegion.getOffset() - offset).trim();
- } catch (BadLocationException e) {
- }
- return null;
- }
-
- protected int getLine(Element element) {
- ElementData data = fOffsetTable.get(element);
- try {
- return (data == null) ? 1 : fTextDocument.getLineOfOffset(data.offset) + 1;
- } catch (Exception e) {
- return 1;
- }
- }
-
- protected int getLine(Element element, String attName) {
- ElementData data = fOffsetTable.get(element);
- try {
- int offset = getAttributeOffset(attName, element.getAttribute(attName), data.offset);
- if (offset != -1)
- return fTextDocument.getLineOfOffset(offset) + 1;
- } catch (BadLocationException e) {
- }
- return getLine(element);
- }
-
- public void validateContent(IProgressMonitor monitor) {
-
- }
-
- public Element getDocumentRoot() {
- if (fRootElement != null)
- fRootElement.normalize();
- return fRootElement;
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
- int x = fTextDocument.get().indexOf("!DOCTYPE"); //$NON-NLS-1$
- if (x > 0) {
- // do something?
- }
- // Prevent the resolution of external entities in order to
- // prevent the parser from accessing the Internet
- // This will prevent huge workbench performance degradations and hangs
- return new InputSource(new StringReader("")); //$NON-NLS-1$
- }
-
-}
diff --git a/ds/org.eclipse.pde.ds.tests/META-INF/MANIFEST.MF b/ds/org.eclipse.pde.ds.tests/META-INF/MANIFEST.MF
index 0893ae3591d..99a807859c8 100644
--- a/ds/org.eclipse.pde.ds.tests/META-INF/MANIFEST.MF
+++ b/ds/org.eclipse.pde.ds.tests/META-INF/MANIFEST.MF
@@ -5,7 +5,6 @@ Bundle-SymbolicName: org.eclipse.pde.ds.tests
Bundle-Version: 1.3.100.qualifier
Bundle-Activator: org.eclipse.pde.internal.ds.tests.Activator
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
- org.junit;bundle-version="3.8.2",
org.eclipse.pde.core;bundle-version="[3.3.0,4.0.0)",
org.eclipse.pde.ds.core;bundle-version="[1.0.0,2.0.0)",
org.eclipse.text;bundle-version="[3.3.0,4.0.0)"
@@ -14,5 +13,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Localization: plugin
Bundle-Vendor: %providerName
Export-Package: org.eclipse.pde.internal.ds.tests;x-internal:=true
+Import-Package: org.junit,
+ org.junit.runner,
+ org.junit.runners
Eclipse-BundleShape: dir
Automatic-Module-Name: org.eclipse.pde.ds.tests
diff --git a/ds/pom.xml b/ds/pom.xml
index 33d6f28561c..8ca46c8af7a 100644
--- a/ds/pom.xml
+++ b/ds/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
eclipse.pde.ds
pom
diff --git a/pom.xml b/pom.xml
index 319afcb33dd..f14b922ca64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
org.eclipse
eclipse-platform-parent
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
../eclipse-platform-parent
diff --git a/ua/org.eclipse.pde.ua.tests/META-INF/MANIFEST.MF b/ua/org.eclipse.pde.ua.tests/META-INF/MANIFEST.MF
index 9cad3c55378..7856f605d97 100644
--- a/ua/org.eclipse.pde.ua.tests/META-INF/MANIFEST.MF
+++ b/ua/org.eclipse.pde.ua.tests/META-INF/MANIFEST.MF
@@ -6,7 +6,6 @@ Bundle-Version: 1.3.100.qualifier
Bundle-ClassPath: tests.jar
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.pde.ua.core;bundle-version="[1.0.0,2.0.0)",
- org.junit;bundle-version="3.8.2",
org.eclipse.text;bundle-version="[3.3.0,4.0.0)",
org.eclipse.pde.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.workbench;bundle-version="[3.5.0,4.0.0)",
@@ -27,3 +26,6 @@ Export-Package: org.eclipse.pde.internal.ua.tests;x-internal:="true",
Bundle-Localization: plugin
Eclipse-BundleShape: dir
Automatic-Module-Name: org.eclipse.pde.ua.tests
+Import-Package: org.junit,
+ org.junit.runner,
+ org.junit.runners
diff --git a/ua/org.eclipse.pde.ua.tests/pom.xml b/ua/org.eclipse.pde.ua.tests/pom.xml
index 497e0952754..6091fffa587 100644
--- a/ua/org.eclipse.pde.ua.tests/pom.xml
+++ b/ua/org.eclipse.pde.ua.tests/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
../../
org.eclipse.pde
diff --git a/ua/pom.xml b/ua/pom.xml
index 077580b3c9c..2e54ea8e925 100644
--- a/ua/pom.xml
+++ b/ua/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
eclipse.pde.ua
pom
diff --git a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
index 3f2bee839eb..f1f8a74eab2 100644
--- a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
@@ -80,11 +80,15 @@ Export-Package:
org.eclipse.pde.unittest.junit",
org.eclipse.pde.internal.core.variables;x-internal:=true
Import-Package: aQute.bnd.build;version="[4.4.0,5.0.0)",
+ aQute.bnd.build.model;version="[4.2.0,5.0.0)",
+ aQute.bnd.header;version="[2.5.0,3.0.0)",
aQute.bnd.osgi;version="[5.5.0,6.0.0)",
aQute.bnd.osgi.repository;version="[3.0.0,4.0.0)",
aQute.bnd.osgi.resource;version="[4.3.0,5.0.0)",
+ aQute.bnd.properties;version="[2.0.0,3.0.0)",
aQute.bnd.service;version="[4.7.0,5.0.0)",
aQute.bnd.version;version="[2.2.0,3.0.0)",
+ aQute.service.reporter;version="[1.2.0,2.0.0)",
org.osgi.service.repository;version="[1.1.0,2.0.0)",
org.osgi.util.promise;version="[1.3.0,2.0.0)"
Require-Bundle:
diff --git a/ui/org.eclipse.pde.core/plugin.xml b/ui/org.eclipse.pde.core/plugin.xml
index 0db7b0acc4b..98dbd6bea98 100644
--- a/ui/org.eclipse.pde.core/plugin.xml
+++ b/ui/org.eclipse.pde.core/plugin.xml
@@ -437,4 +437,12 @@
class="org.eclipse.pde.internal.core.LocalMavenPluginSourcePathLocator"
complexity="low"/>
+
+
+
+
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/AbstractModel.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/AbstractModel.java
index 0879219d8aa..e7adcea368b 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/AbstractModel.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/AbstractModel.java
@@ -40,7 +40,6 @@
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.core.IModelChangedListener;
import org.eclipse.pde.core.ModelChangedEvent;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.xml.sax.SAXException;
public abstract class AbstractModel extends PlatformObject implements IModel, IModelChangeProviderExtension, Serializable {
@@ -236,8 +235,9 @@ public void throwParseErrorsException(Throwable e) throws CoreException {
throw new CoreException(Status.error("Error in the manifest file", e)); //$NON-NLS-1$
}
+ @SuppressWarnings("restriction")
protected SAXParser getSaxParser() throws ParserConfigurationException, SAXException, FactoryConfigurationError {
- return PDEXmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
+ return org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
}
@Override
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java
index 296fe280405..c91bf2bbf32 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2021 IBM Corporation and others.
+ * Copyright (c) 2005, 2023 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* EclipseSource Corporation - ongoing enhancements
+ * Hannes Wellmann - Enhance computation of system-package provided by a ExecutionEnvironment
*******************************************************************************/
package org.eclipse.pde.internal.core;
@@ -22,15 +23,26 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMInstallChangedListener;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.PropertyChangeEvent;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
@@ -242,6 +254,88 @@ protected boolean initializePlatformProperties() {
return false;
}
+ static {
+ // Listen to changes in the available VMInstalls and
+ // ExecutionEnvironment defaults
+ @SuppressWarnings("restriction")
+ String nodeQualifier = org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN;
+ IEclipsePreferences launchingNode = InstanceScope.INSTANCE.getNode(nodeQualifier);
+ launchingNode.addPreferenceChangeListener(e -> {
+ if (e.getKey().equals("org.eclipse.jdt.launching.PREF_DEFAULT_ENVIRONMENTS_XML")) { //$NON-NLS-1$
+ Object oldValue = e.getOldValue() == null ? "" : e.getOldValue(); //$NON-NLS-1$
+ Object newValue = e.getNewValue() == null ? "" : e.getNewValue(); //$NON-NLS-1$
+ if (!oldValue.equals(newValue)) {
+ triggerSystemPackagesReload();
+ }
+ }
+ });
+ JavaRuntime.addVMInstallChangedListener(new IVMInstallChangedListener() {
+ @Override
+ public void vmRemoved(IVMInstall vm) {
+ triggerSystemPackagesReload();
+ }
+
+ @Override
+ public void vmChanged(PropertyChangeEvent event) {
+ triggerSystemPackagesReload();
+ }
+
+ @Override
+ public void vmAdded(IVMInstall vm) {
+ triggerSystemPackagesReload();
+ }
+
+ @Override
+ public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) {
+ triggerSystemPackagesReload();
+ }
+ });
+ }
+ private static final String PDE_MANIFEST_BUILDER = "org.eclipse.pde.ManifestBuilder"; //$NON-NLS-1$
+
+ public static void triggerSystemPackagesReload() {
+ final String jobFamily = "pde.internal.ReresolveStateAfterVMorEEchanges"; //$NON-NLS-1$
+ Job.getJobManager().cancel(jobFamily);
+ WorkspaceJob job = new WorkspaceJob("Re-resolve Target state after VM-Install or EE change") { //$NON-NLS-1$
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ // The list of EEs has changed: re-read all available
+ // VM-installs/EEs and re-resolve state with new properties
+ return reloadSystemPackagesIntoState();
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return jobFamily.equals(family);
+ }
+ };
+ job.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ job.schedule(200); // Small delay to bulk-handle multiple changes
+ }
+
+ // Visible for testing only
+ public static IStatus reloadSystemPackagesIntoState() {
+ MinimalState state = PDECore.getDefault().getModelManager().getState();
+ if (state.fNoProfile) {
+ return Status.OK_STATUS;
+ }
+ state.fEEListChanged = true;
+ StateDelta delta = state.internalResolveState(true);
+ if (delta.getChanges().length == 0) {
+ return Status.OK_STATUS;
+ }
+ // Perform PDE-Manifest build, to re-validate all Manifests
+ MultiStatus status = new MultiStatus(MinimalState.class, 0, "Reload of JRE system-packages encountered issues"); //$NON-NLS-1$
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ try {
+ project.build(IncrementalProjectBuilder.FULL_BUILD, PDE_MANIFEST_BUILDER, null, null);
+ } catch (CoreException e) { // ignore
+ status.add(e.getStatus());
+ }
+ }
+ return status;
+ }
+
public void removeBundleDescription(BundleDescription description) {
if (description != null) {
fState.removeBundle(description);
@@ -269,7 +363,7 @@ private void setExecutionEnvironments() {
if (!fNoProfile) {
fExecutionEnvironments = knownExecutionEnviroments;
}
- fEEListChanged = true; // alway indicate the list has changed
+ fEEListChanged = true; // always indicate the list has changed
}
public void addBundleDescription(BundleDescription toAdd) {
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEAuxiliaryState.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEAuxiliaryState.java
index 47253f4a8ef..4ccd344d307 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEAuxiliaryState.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEAuxiliaryState.java
@@ -32,7 +32,6 @@
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.w3c.dom.Document;
@@ -202,7 +201,8 @@ public boolean exportsExternalAnnotations(long bundleID) {
*/
protected void savePluginInfo(File dir) {
try {
- Document doc = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE().newDocument();
+ @SuppressWarnings("restriction")
+ Document doc = org.eclipse.core.internal.runtime.XmlProcessorFactory.newDocumentWithErrorOnDOCTYPE();
Element root = doc.createElement(ELEMENT_ROOT);
Iterator iter = fPluginInfos.keySet().iterator();
@@ -261,7 +261,9 @@ protected boolean readPluginInfoCache(File dir) {
File file = new File(dir, CACHE_EXTENSION);
if (file.exists() && file.isFile()) {
try {
- DocumentBuilder documentBuilder = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ @SuppressWarnings("restriction")
+ DocumentBuilder documentBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createDocumentBuilderWithErrorOnDOCTYPE();
documentBuilder.setErrorHandler(new DefaultHandler());
Document doc = documentBuilder.parse(file);
Element root = doc.getDocumentElement();
@@ -300,9 +302,9 @@ protected boolean exists(File dir) {
*/
public static void writePluginInfo(IPluginModelBase[] models, File destination) {
try {
- DocumentBuilder builder = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
- Document doc = builder.newDocument();
-
+ @SuppressWarnings("restriction")
+ Document doc = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .newDocumentWithErrorOnDOCTYPE();
Element root = doc.createElement(ELEMENT_ROOT);
doc.appendChild(root);
for (int i = 0; i < models.length; i++) {
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java
index 89d5936277b..74f80f4f17b 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECoreMessages.java
@@ -231,8 +231,6 @@ public class PDECoreMessages extends NLS {
public static String BundleErrorReporter_exportNoJRE;
- public static String BundleErrorReporter_importNoJRE;
-
public static String ManifestConsistencyChecker_0;
public static String ManifestConsistencyChecker_buildDoesNotExist;
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java
index 45487b312b7..9bd67b371f9 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.pde.internal.core;
+import static org.eclipse.pde.internal.core.DependencyManager.Options.INCLUDE_OPTIONAL_DEPENDENCIES;
+
import java.io.File;
import java.util.ArrayDeque;
import java.util.ArrayList;
@@ -22,6 +24,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
@@ -60,13 +63,18 @@
public class RequiredPluginsClasspathContainer extends PDEClasspathContainer implements IClasspathContainer {
@SuppressWarnings("nls")
- private static final Collection JUNIT5_RUNTIME_PLUGINS = Set.of("org.junit", "junit-jupiter-api",
- "junit-jupiter-engine", "junit-platform-commons", "junit-platform-engine", "org.hamcrest.core",
- "org.opentest4j");
+ private static final Set JUNIT5_RUNTIME_PLUGINS = Set.of("org.junit", //
+ "junit-jupiter-engine", // BSN of the bundle from Maven-Central
+ "org.junit.jupiter.engine"); // BSN of the bundle from Eclipse-Orbit
+ @SuppressWarnings("nls")
+ private static final Set JUNIT5_API_PLUGINS = Set.of( //
+ "junit-jupiter-api", // BSN of the bundle from Maven-Central
+ "org.junit.jupiter.api"); // BSN of the bundle from Eclipse-Orbit
private final IPluginModelBase fModel;
private IBuild fBuild;
+ private List junit5RuntimeClosure;
private IClasspathEntry[] fEntries;
private boolean addImportedPackages;
@@ -489,18 +497,16 @@ private void addJunit5RuntimeDependencies(Set added, List added, List> rules = Map.of(desc, List.of());
addPlugin(desc, true, rules, entries);
}
+ }
+ private boolean containsJunit5Dependency(Collection dependencies) {
+ return dependencies.stream().map(BundleDescription::getSymbolicName).anyMatch(JUNIT5_API_PLUGINS::contains);
}
- private static boolean containsJunit5Dependency(Collection dependencies) {
- return dependencies.stream().anyMatch(desc -> "junit-jupiter-api".equals(desc.getName()) || "org.junit.jupiter.api".equals(desc.getName())); //$NON-NLS-1$ //$NON-NLS-2$
+ private static List collectJunit5RuntimeRequirements() {
+ List roots = JUNIT5_RUNTIME_PLUGINS.stream().map(PluginRegistry::findModel)
+ .filter(Objects::nonNull).filter(IPluginModelBase::isEnabled)
+ .map(IPluginModelBase::getBundleDescription).toList();
+ Set closure = DependencyManager.findRequirementsClosure(roots,
+ INCLUDE_OPTIONAL_DEPENDENCIES);
+ String systemBundleBSN = TargetPlatformHelper.getPDEState().getSystemBundle();
+ return closure.stream().filter(b -> !b.getSymbolicName().equals(systemBundleBSN)).toList();
}
private void addSecondaryDependencies(BundleDescription desc, Set added,
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java
index 949274f5af4..fe0784ae4b1 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2022 IBM Corporation and others.
+ * Copyright (c) 2000, 2023 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -22,7 +22,6 @@
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
@@ -45,8 +44,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.osgi.service.resolver.BundleDescription;
@@ -354,14 +351,11 @@ public static Dictionary getTargetEnvironment(MinimalState state
}
@SuppressWarnings("unchecked")
- public static Dictionary[] getPlatformProperties(String[] profiles, MinimalState state) {
- if (profiles == null || profiles.length == 0) {
- return new Dictionary[] { getTargetEnvironment(state) };
- }
-
+ public static Dictionary[] getPlatformProperties(String[] profilesArr, MinimalState state) {
+ List profiles = profilesArr != null ? Arrays.asList(profilesArr) : List.of();
// add java profiles for those EE's that have a .profile file in the
// current system bundle
- List> result = new ArrayList<>(profiles.length);
+ List> result = new ArrayList<>(profiles.size());
for (String profile : profiles) {
IExecutionEnvironment environment = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(profile);
if (environment != null) {
@@ -381,10 +375,7 @@ public static Dictionary[] getPlatformProperties(String[] profil
public static void addEnvironmentProperties(Dictionary properties,
IExecutionEnvironment environment, Properties profileProps) {
- String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
- if (systemPackages == null) { // java 10 and beyond
- systemPackages = querySystemPackages(environment);
- }
+ String systemPackages = getSystemPackages(environment, profileProps);
if (systemPackages != null) {
properties.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages);
}
@@ -396,54 +387,8 @@ public static void addEnvironmentProperties(Dictionary propertie
}
}
- @SuppressWarnings("restriction")
- public static String querySystemPackages(IExecutionEnvironment environment) {
- IVMInstall vm = bestVmInstallFor(environment);
- if (vm == null || !JavaRuntime.isModularJava(vm)) {
- return null;
- }
- String release = environment.getProfileProperties().getProperty(JavaCore.COMPILER_COMPLIANCE);
- try {
- Collection packages = new TreeSet<>();
- String jrtPath = "lib/" + org.eclipse.jdt.internal.compiler.util.JRTUtil.JRT_FS_JAR; //$NON-NLS-1$
- String path = new File(vm.getInstallLocation(), jrtPath).toString(); // $NON-NLS-1$
- var jrt = org.eclipse.jdt.internal.core.builder.ClasspathLocation.forJrtSystem(path, null, null, release);
- for (String moduleName : jrt.getModuleNames(null)) {
- var module = jrt.getModule(moduleName);
- if (module == null) {
- continue;
- }
- for (var packageExport : module.exports()) {
- if (!packageExport.isQualified()) {
- packages.add(new String(packageExport.name()));
- }
- }
- }
- return String.join(",", packages); //$NON-NLS-1$
- } catch (CoreException e) {
- PDECore.logException(e, "failed to read system packages for " + environment); //$NON-NLS-1$
- }
- return null;
- }
-
- private static IVMInstall bestVmInstallFor(IExecutionEnvironment environment) {
- if (environment == null) {
- return null;
- }
- IVMInstall defaultVM = environment.getDefaultVM();
- if (defaultVM != null) {
- return defaultVM;
- }
- IVMInstall[] compatible = environment.getCompatibleVMs();
- if (compatible.length == 0) {
- return null;
- }
- for (IVMInstall vm : compatible) {
- if (environment.isStrictlyCompatible(vm)) {
- return vm;
- }
- }
- return compatible[0];
+ public static String getSystemPackages(IExecutionEnvironment environment, Properties profileProperties) {
+ return org.eclipse.pde.internal.build.site.PDEState.getSystemPackages(environment, profileProperties);
}
public static String[] getKnownExecutionEnvironments() {
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/XMLDefaultHandler.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/XMLDefaultHandler.java
index 76f69859369..50c448ca4dd 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/XMLDefaultHandler.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/XMLDefaultHandler.java
@@ -18,7 +18,6 @@
import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
@@ -73,9 +72,10 @@ public void setDocumentLocator(Locator locator) {
}
@Override
+ @SuppressWarnings("restriction")
public void startDocument() throws SAXException {
try {
- fDocument = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE().newDocument();
+ fDocument = org.eclipse.core.internal.runtime.XmlProcessorFactory.newDocumentWithErrorOnDOCTYPE();
} catch (ParserConfigurationException e) {
}
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndBadLocationException.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBadLocationException.java
similarity index 95%
rename from ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndBadLocationException.java
rename to ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBadLocationException.java
index a8569b92583..71de55d9bba 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndBadLocationException.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBadLocationException.java
@@ -11,7 +11,7 @@
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
-package org.eclipse.pde.internal.ui.editor.bnd;
+package org.eclipse.pde.internal.core.bnd;
import org.eclipse.jface.text.BadLocationException;
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java
index dd9e8c78c6a..f77fb468053 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndBuilder.java
@@ -35,6 +35,7 @@
import org.eclipse.pde.internal.core.ICoreConstants;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDECoreMessages;
+import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
import org.eclipse.pde.internal.core.natures.BndProject;
import org.eclipse.pde.internal.core.project.PDEProject;
@@ -86,6 +87,14 @@ public void done(IJobChangeEvent event) {
return new IProject[] { project };
}
+ @Override
+ protected void clean(IProgressMonitor monitor) throws CoreException {
+ IFile file = getProject().getFile(BndProject.INSTRUCTIONS_FILE);
+ if (file.exists()) {
+ file.deleteMarkers(PDEMarkerFactory.MARKER_ID, true, IResource.DEPTH_ZERO);
+ }
+ }
+
private static final class BndBuild implements ICoreRunnable {
private IProject project;
@@ -127,6 +136,7 @@ private static void buildProjectJar(IProject project, IProgressMonitor monitor)
ProjectJar jar = new ProjectJar(project, CLASS_FILTER);
builder.setJar(jar);
builder.build();
+ new BndErrorReporter(project, bnd).validateContent(monitor);
}
if (monitor.isCanceled()) {
return;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndDocument.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndDocument.java
similarity index 87%
rename from ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndDocument.java
rename to ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndDocument.java
index bc19f0fc98a..06c4659665e 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndDocument.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndDocument.java
@@ -11,7 +11,7 @@
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
-package org.eclipse.pde.internal.ui.editor.bnd;
+package org.eclipse.pde.internal.core.bnd;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -21,7 +21,7 @@
/**
* This class wraps from JFace text framework to bnd-document
*/
-final class BndDocument implements aQute.bnd.properties.IDocument {
+public final class BndDocument implements aQute.bnd.properties.IDocument {
private final IDocument document;
@@ -43,6 +43,14 @@ public IRegion getLineInformation(int lineNum) throws BndBadLocationException {
}
}
+ public int getLineOfOffset(int offset) throws BndBadLocationException {
+ try {
+ return document.getLineOfOffset(offset);
+ } catch (BadLocationException e) {
+ throw new BndBadLocationException(e);
+ }
+ }
+
@Override
public String get() {
return document.get();
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndErrorReporter.java
new file mode 100644
index 00000000000..5fae1a90db0
--- /dev/null
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndErrorReporter.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2023 Christoph Läubrich and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christoph Läubrich - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.core.bnd;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.pde.internal.core.builders.CompilerFlags;
+import org.eclipse.pde.internal.core.builders.ErrorReporter;
+import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
+import org.eclipse.pde.internal.core.natures.BndProject;
+
+import aQute.bnd.properties.IRegion;
+import aQute.bnd.properties.LineType;
+import aQute.bnd.properties.PropertiesLineReader;
+import aQute.service.reporter.Report;
+import aQute.service.reporter.Report.Location;
+
+public class BndErrorReporter extends ErrorReporter {
+
+ private BndDocument bndDocument;
+ private Report report;
+
+ public BndErrorReporter(IProject project, Report report) {
+ super(project.getFile(BndProject.INSTRUCTIONS_FILE));
+ this.report = report;
+ IDocument document = createDocument(fFile);
+ if (document != null) {
+ bndDocument = new BndDocument(document);
+ }
+ }
+
+ @Override
+ protected void validate(IProgressMonitor monitor) {
+ if (report != null) {
+ for (String warn : report.getWarnings()) {
+ reportProblem(warn, CompilerFlags.WARNING, report.getLocation(warn));
+ }
+ for (String err : report.getErrors()) {
+ reportProblem(err, CompilerFlags.ERROR, report.getLocation(err));
+ }
+ }
+ }
+
+ private void reportProblem(String err, int severity, Location location) {
+ int line = -1;
+ if (location != null) {
+ if (location.line > 0) {
+ line = location.line;
+ } else if (location.header != null && bndDocument != null) {
+ try {
+ PropertiesLineReader reader = new PropertiesLineReader(bndDocument);
+ LineType type = reader.next();
+ while (type != LineType.eof) {
+ if (type == LineType.entry) {
+ String key = reader.key();
+ if (location.header.equals(key)) {
+ IRegion region = reader.region();
+ line = bndDocument.getLineOfOffset(region.getOffset()) + 1;
+ break;
+ }
+ }
+ type = reader.next();
+ }
+ } catch (Exception e) {
+ // can't do anything here then...
+ }
+ }
+ }
+ report(err, line, severity, PDEMarkerFactory.CAT_FATAL);
+ }
+
+}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndRegion.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndRegion.java
similarity index 89%
rename from ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndRegion.java
rename to ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndRegion.java
index 3df2f8ca785..00b5e035563 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndRegion.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndRegion.java
@@ -11,7 +11,7 @@
* Contributors:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
-package org.eclipse.pde.internal.ui.editor.bnd;
+package org.eclipse.pde.internal.core.bnd;
import org.eclipse.jface.text.IRegion;
@@ -35,4 +35,9 @@ public int getLength() {
public int getOffset() {
return textRegion.getOffset();
}
+
+ @Override
+ public String toString() {
+ return textRegion.toString();
+ }
}
\ No newline at end of file
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java
index 2b230aea848..64e5895566c 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BuildErrorReporter.java
@@ -70,7 +70,6 @@
import org.eclipse.pde.internal.core.text.build.BuildEntry;
import org.eclipse.pde.internal.core.text.build.BuildModel;
import org.eclipse.pde.internal.core.util.CoreUtility;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.eclipse.pde.internal.core.util.PatternConstructor;
import org.osgi.framework.Constants;
import org.w3c.dom.Document;
@@ -691,7 +690,9 @@ private void validateBinIncludes(IBuildEntry binIncludes, List outp
// if we're defining fragments, make sure they have entries in plugin.xml
private void validateFragmentContributions(IBuildEntry binIncludes) {
try {
- DocumentBuilder newDocumentBuilder = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ @SuppressWarnings("restriction")
+ DocumentBuilder newDocumentBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createDocumentBuilderWithErrorOnDOCTYPE();
newDocumentBuilder.setErrorHandler(new PDEErrorHandler());
Document doc = newDocumentBuilder.parse(PDEProject.getPluginXml(fProject).getContents());
XPath xpath = XPathFactory.newInstance().newXPath();
@@ -707,7 +708,9 @@ private void validateFragmentContributions(IBuildEntry binIncludes) {
// if we're defining an application, make sure it has entries in plugin.xml
private void validateApplicationContributions(IBuildEntry binIncludes) {
try {
- DocumentBuilder newDocumentBuilder = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ @SuppressWarnings("restriction")
+ DocumentBuilder newDocumentBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createDocumentBuilderWithErrorOnDOCTYPE();
newDocumentBuilder.setErrorHandler(new PDEErrorHandler());
Document doc = newDocumentBuilder.parse(PDEProject.getPluginXml(fProject).getContents());
XPath xpath = XPathFactory.newInstance().newXPath();
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java
index de3169bdd11..a41e5ad581a 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java
@@ -1208,19 +1208,10 @@ private void validateImportPackage(IProgressMonitor monitor) {
int length = element.getValueComponents().length;
for (int j = 0; j < length; j++) {
ImportPackageSpecification importSpec = imports[index++];
- String name = importSpec.getName();
- if (name.equals("java") || name.startsWith("java.")) { //$NON-NLS-1$ //$NON-NLS-2$
- IHeader jreHeader = getHeader(ICoreConstants.ECLIPSE_JREBUNDLE);
- if (jreHeader == null || !"true".equals(jreHeader.getValue())) { //$NON-NLS-1$
- report(PDECoreMessages.BundleErrorReporter_importNoJRE, getPackageLine(header, element), CompilerFlags.ERROR, PDEMarkerFactory.M_JAVA_PACKAGE__PORTED, PDEMarkerFactory.CAT_FATAL);
- continue;
- }
- }
-
if (importSpec.isResolved() || !isCheckUnresolvedImports()) {
continue;
}
-
+ String name = importSpec.getName();
boolean optional = isOptional(element);
int severity = getRequireBundleSeverity(element, optional);
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/DefaultSAXParser.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/DefaultSAXParser.java
index c1d9bd842dc..f7d118944be 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/DefaultSAXParser.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/DefaultSAXParser.java
@@ -18,17 +18,20 @@
import java.io.InputStream;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.pde.internal.core.util.SAXParserWrapper;
import org.xml.sax.SAXException;
public class DefaultSAXParser {
public static void parse(IFile file, XMLErrorReporter reporter) {
try (InputStream stream = new BufferedInputStream(file.getContents())) {
- SAXParserWrapper.parse(stream, reporter);
+ @SuppressWarnings("restriction")
+ SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory
+ .createSAXParserWithErrorOnDOCTYPE();
+ parser.parse(stream, reporter);
} catch (CoreException | SAXException | IOException | ParserConfigurationException e) {
}
}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java
index a381b6a0983..92c27ebaa21 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionPointSchemaBuilder.java
@@ -138,7 +138,7 @@ private void compileFile(IFile file, IProgressMonitor monitor) {
SchemaErrorReporter reporter = new SchemaErrorReporter(file);
DefaultSAXParser.parse(file, reporter);
- reporter.validate(monitor);
+ reporter.validateContent(monitor);
try (StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter(swriter)) {
boolean generateDoc = CompilerFlags.getBoolean(file.getProject(), CompilerFlags.S_CREATE_DOCS);
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/IncrementalErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/IncrementalErrorReporter.java
index 7eda1bcec88..85f5d8ebb90 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/IncrementalErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/IncrementalErrorReporter.java
@@ -27,11 +27,17 @@
public class IncrementalErrorReporter {
private final IResource fResource;
+ private final String fMarkerID;
private final Collection fReportedMarkers = new ArrayList<>();
private int fErrorCount;
public IncrementalErrorReporter(IResource file) {
+ this(file, PDEMarkerFactory.MARKER_ID);
+ }
+
+ public IncrementalErrorReporter(IResource file, String markerID) {
fResource = file;
+ fMarkerID = markerID;
}
public VirtualMarker addMarker(String message, int lineNumber, int severity, int problemID, String category) {
@@ -62,13 +68,13 @@ public void applyMarkers() {
// This seem to be for compatibility with some legacy code,
// PDE builders don't create markers with this type anymore
fResource.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
- existingMarkers = fResource.findMarkers(PDEMarkerFactory.MARKER_ID, false, IResource.DEPTH_ZERO);
+ existingMarkers = fResource.findMarkers(fMarkerID, false, IResource.DEPTH_ZERO);
} catch (CoreException e) {
PDECore.logException(e);
// If we can't read existing, let delete them before we create new
existingMarkers = new IMarker[0];
try {
- fResource.deleteMarkers(PDEMarkerFactory.MARKER_ID, false, IResource.DEPTH_ZERO);
+ fResource.deleteMarkers(fMarkerID, false, IResource.DEPTH_ZERO);
} catch (CoreException e1) {
PDECore.logException(e1);
}
@@ -112,7 +118,7 @@ public void applyMarkers() {
// Create only new markers
for (VirtualMarker reportedMarker : fReportedMarkers) {
try {
- fResource.createMarker(PDEMarkerFactory.MARKER_ID, reportedMarker.getAttributes());
+ fResource.createMarker(fMarkerID, reportedMarker.getAttributes());
} catch (CoreException e) {
PDECore.logException(e);
}
@@ -139,7 +145,7 @@ public Map getAttributes() {
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("VirtualMarker ["); //$NON-NLS-1$
- if (fAttributes != null) {
+ if (!fAttributes.isEmpty()) {
builder.append("attributes="); //$NON-NLS-1$
builder.append(fAttributes);
}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java
index bd0be468d81..e607025c689 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/UpdateSiteBuilder.java
@@ -97,7 +97,7 @@ private void checkFile(IFile file, IProgressMonitor monitor) {
UpdateSiteErrorReporter reporter = new UpdateSiteErrorReporter(file);
DefaultSAXParser.parse(file, reporter);
if (reporter.getErrorCount() == 0) {
- reporter.validate(monitor);
+ reporter.validateContent(monitor);
}
monitor.subTask(PDECoreMessages.Builders_updating);
monitor.done();
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java
index 5555dae497b..5e512dbe3d7 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/XMLErrorReporter.java
@@ -15,9 +15,11 @@
package org.eclipse.pde.internal.core.builders;
import java.io.StringReader;
+import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Deque;
import java.util.HashMap;
-import java.util.Stack;
+import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
@@ -38,7 +40,7 @@
import org.eclipse.pde.internal.core.PDECoreMessages;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
import org.eclipse.pde.internal.core.builders.IncrementalErrorReporter.VirtualMarker;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
+import org.eclipse.pde.internal.core.util.PDEXMLHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -75,7 +77,7 @@ public ElementData(int offset) {
private IDocument fTextDocument;
- private Stack fElementStack;
+ private Deque fElementStack;
private Element fRootElement;
@@ -90,7 +92,11 @@ public ElementData(int offset) {
private double fSchemaVersion = 2.1;
public XMLErrorReporter(IFile file) {
- fErrorReporter = new IncrementalErrorReporter(file);
+ this(file, PDEMarkerFactory.MARKER_ID);
+ }
+
+ public XMLErrorReporter(IFile file, String markerType) {
+ fErrorReporter = new IncrementalErrorReporter(file, markerType);
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
try {
@@ -101,7 +107,7 @@ public XMLErrorReporter(IFile file) {
manager.disconnect(file.getFullPath(), LocationKind.NORMALIZE, null);
fFindReplaceAdapter = new FindReplaceDocumentAdapter(fTextDocument);
fOffsetTable = new HashMap<>();
- fElementStack = new Stack<>();
+ fElementStack = new ArrayDeque<>();
} catch (CoreException e) {
PDECore.log(e);
}
@@ -200,9 +206,10 @@ public void warning(SAXParseException exception) throws SAXException {
}
@Override
+ @SuppressWarnings("restriction")
public void startDocument() throws SAXException {
try {
- fXMLDocument = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE().newDocument();
+ fXMLDocument = org.eclipse.core.internal.runtime.XmlProcessorFactory.newDocumentWithErrorOnDOCTYPE();
} catch (ParserConfigurationException e) {
}
}
@@ -268,13 +275,9 @@ public void setDocumentLocator(Locator locator) {
private int getStartOffset(String elementName) throws BadLocationException {
int line = fLocator.getLineNumber();
- int col = fLocator.getColumnNumber();
- if (col < 0) {
- col = fTextDocument.getLineLength(line);
- }
String text = fTextDocument.get(fHighestOffset + 1, fTextDocument.getLineOffset(line) - fHighestOffset - 1);
- ArrayList commentPositions = new ArrayList<>();
+ List commentPositions = new ArrayList<>();
for (int idx = 0; idx < text.length();) {
idx = text.indexOf(" javax.annotation bundle must not be on the classpath
- List classpathEntries = getRequiredPluginContainerEntries(project);
- assertThat(classpathEntries).isEmpty();
+ try (var mocked = mockExtraExtraJRESystemPackages("JavaSE-1.8", List.of("javax.annotation"))) {
+ IProject project = ProjectUtils
+ .importTestProject("tests/projects/demoMissedSystemPackageJava8OsgiEERequirement");
+ // bundle is build with java 11, but declares java 8 requirement via
+ // Require-Capability
+ // --> javax.annotation bundle must not be on the classpath
+ List classpathEntries = getRequiredPluginContainerEntries(project);
+ assertThat(classpathEntries).isEmpty();
+ }
}
// --- utilitiy methods ---
@@ -153,4 +162,30 @@ private void loadTargetPlatform(String bundleName) throws Exception {
Predicate bundleFilter = b -> bundleNames.contains(b.getSymbolicName());
TargetPlatformUtil.setRunningPlatformSubSetAsTarget("Target containing " + bundleName, bundleFilter);
}
+
+ private AutoCloseable mockExtraExtraJRESystemPackages(String eeId, List extraPackages) {
+ // We want to test that the packages provided by a Java-1.8 VM are
+ // consumed from the VM and not from another bundle in the TP.
+ // Unfortunately we don't have a Java-1.8 VM in the CI, it is always a
+ // more recent one, but more recent ones don't contain the packages we
+ // want anymore. Therefore we have to mock the TP system-properties and
+ // pretend the desired package are contained in the VM for the purpose
+ // of this test.
+
+ IExecutionEnvironment ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(eeId);
+ Properties profileProps = ee.getProfileProperties();
+ String mockedSystemPackages = TargetPlatformHelper.getSystemPackages(ee, profileProps)
+ + "," + String.join(",", extraPackages);
+
+ var mockedPDEState = Mockito.mockStatic(TargetPlatformHelper.class, Mockito.CALLS_REAL_METHODS);
+ mockedPDEState.when(() -> TargetPlatformHelper.getSystemPackages(ee, profileProps))
+ .thenReturn(mockedSystemPackages);
+ // Beware that the static mock is thread-local!
+ MinimalState.reloadSystemPackagesIntoState();
+ mockedPDEState.verify(() -> TargetPlatformHelper.getSystemPackages(ee, profileProps), Mockito.times(1));
+ return () -> {
+ mockedPDEState.close();
+ MinimalState.reloadSystemPackagesIntoState();
+ };
+ }
}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java
index 80fda47779e..ace955cf260 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/core/builders/BundleErrorReporterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2021 Julian Honnen
+ * Copyright (c) 2021, 2023 Julian Honnen
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -27,7 +27,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.pde.core.IBaseModel;
-import org.eclipse.pde.internal.core.builders.CompilerFlags;
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
@@ -52,7 +51,7 @@ public void setup() throws Exception {
@Test
public void testErrorOnUnresolvedJrePackage() throws Exception {
IProject project = ProjectUtils.createPluginProject(manifest.getProject().getName(),
- JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("JavaSE-11")).getProject();
+ JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("JavaSE-1.8")).getProject();
IFile manifest = project.getFile("META-INF/MANIFEST.MF");
PDEModelUtility.modifyModel(new ModelModification(manifest) {
@@ -60,7 +59,7 @@ public void testErrorOnUnresolvedJrePackage() throws Exception {
protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException {
IBundlePluginModelBase modelBase = (IBundlePluginModelBase) model;
IBundle bundle = modelBase.getBundleModel().getBundle();
- bundle.setHeader(Constants.IMPORT_PACKAGE, "javax.xml.ws");
+ bundle.setHeader(Constants.IMPORT_PACKAGE, "java.lang.module");
}
}, null);
@@ -72,7 +71,7 @@ protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws Co
protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException {
IBundlePluginModelBase modelBase = (IBundlePluginModelBase) model;
IBundle bundle = modelBase.getBundleModel().getBundle();
- bundle.setHeader(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.8");
+ bundle.setHeader(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-11");
}
};
PDEModelUtility.modifyModel(modification, null);
@@ -82,9 +81,8 @@ protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws Co
private List findUnresolvedImportsMarkers() throws CoreException {
manifest.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- return Arrays.stream(manifest.findMarkers(PDEMarkerFactory.MARKER_ID, false, 0)).filter(
- m -> m.getAttribute(PDEMarkerFactory.compilerKey, "").equals(CompilerFlags.P_UNRESOLVED_IMPORTS))
- .toList();
+ return Arrays.stream(manifest.findMarkers(PDEMarkerFactory.MARKER_ID, false, 0))
+ .filter(m -> m.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR).toList();
}
@After
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/feature/FeatureDataTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/feature/FeatureDataTestCase.java
index fc29f0cba64..bda388d715f 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/feature/FeatureDataTestCase.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/core/tests/internal/feature/FeatureDataTestCase.java
@@ -22,11 +22,11 @@
import javax.xml.parsers.DocumentBuilder;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.internal.core.feature.FeatureData;
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -91,7 +91,7 @@ private String toXml(FeatureData data) {
}
public static FeatureData fromXml(String xml) throws Exception {
- DocumentBuilder builder = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ DocumentBuilder builder = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
InputSource is = new InputSource(new StringReader(xml));
Document doc = builder.parse(is);
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExecutionEnvironmentTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExecutionEnvironmentTests.java
index 99bfba9e04c..df23d138344 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExecutionEnvironmentTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/ExecutionEnvironmentTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2022 IBM Corporation and others.
+ * Copyright (c) 2008, 2023 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -324,7 +324,7 @@ public void testMinimumComplianceNoOverwrite() throws Exception {
@Test
public void testDynamicSystemPackages() throws Exception {
IExecutionEnvironment env = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("JavaSE-11");
- String systemPackages = TargetPlatformHelper.querySystemPackages(env);
+ String systemPackages = TargetPlatformHelper.getSystemPackages(env, null);
assertThat(systemPackages).isNotNull();
assertThat(systemPackages.split(",")).contains("java.lang", "javax.sql", "org.w3c.dom.css");
}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java
index 65be6e79d14..b3142553a2e 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/SchemaTraversePerfTest.java
@@ -18,9 +18,9 @@
import java.net.JarURLConnection;
import java.net.URLConnection;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.pde.internal.core.XMLDefaultHandler;
import org.eclipse.pde.internal.core.schema.EditableSchema;
-import org.eclipse.pde.internal.core.util.SAXParserWrapper;
import org.eclipse.pde.internal.core.util.SchemaUtil;
public class SchemaTraversePerfTest extends AbstractSchemaPerfTest {
@@ -44,7 +44,7 @@ protected void executeTest() throws Exception {
URLConnection connection = SchemaUtil.getURLConnection(fXSDFile.toURI().toURL());
try (InputStream input = connection.getInputStream()) {
XMLDefaultHandler handler = new XMLDefaultHandler(true);
- SAXParserWrapper.parse(input, handler);
+ XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE().parse(input, handler);
EditableSchema schema = new EditableSchema("pluginID", "pointID", "name", true);
schema.traverseDocumentTree(handler.getDocumentElement());
} finally {
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java
index a5333bc83e1..53d9bc2b39c 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java
@@ -50,6 +50,7 @@
import org.eclipse.pde.ui.tests.util.TestBundleCreator;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
+import org.junit.Assert;
import org.osgi.framework.Version;
/**
@@ -117,7 +118,7 @@ public void testSearchModelRegistry() throws Exception {
// Create a workspace model
IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject proj = ws.getRoot().getProject(SEARCH_TEST_WORKSPACE_NAME);
- assertFalse("Project should not exist", proj.exists());
+ Assert.assertFalse("Project should not exist", proj.exists());
IBundleProjectDescription description = service.getDescription(proj);
description.setSymbolicName(SEARCH_TEST_WORKSPACE_NAME);
description.setBundleVersion(new Version("1.1.1"));
@@ -203,19 +204,19 @@ public void testSearchModelRegistry() throws Exception {
private void executeSearchTest() {
IPluginModelBase[] models;
models = PluginRegistry.getAllModels();
- assertEquals(SEARCH_TEST_EXTERNAL_COUNT + 1, models.length);
+ Assert.assertEquals(SEARCH_TEST_EXTERNAL_COUNT + 1, models.length);
models = PluginRegistry.getWorkspaceModels();
- assertEquals(1, models.length);
+ Assert.assertEquals(1, models.length);
models = PluginRegistry.getExternalModels();
- assertEquals(SEARCH_TEST_EXTERNAL_COUNT, models.length);
+ Assert.assertEquals(SEARCH_TEST_EXTERNAL_COUNT, models.length);
IPluginModelBase model;
IWorkspace ws = ResourcesPlugin.getWorkspace();
model = PluginRegistry.findModel(SEARCH_TEST_WORKSPACE_NAME);
- assertNotNull(model);
+ Assert.assertNotNull(model);
IProject project = ws.getRoot().getProject(SEARCH_TEST_WORKSPACE_NAME);
model = PluginRegistry.findModel(project);
- assertNotNull(model);
+ Assert.assertNotNull(model);
model = PluginRegistry.findModel(SEARCH_TEST_EXTERNAL_NAME);
openRequiredBundles(model, new HashSet<>());
@@ -230,7 +231,7 @@ private void executeSearchTest() {
* @param allBundleNames set of symbolic names that have been looked up to prevent stack overflows
*/
private void openRequiredBundles(IPluginModelBase model, Set allBundleNames) {
- assertNotNull(model);
+ Assert.assertNotNull(model);
BundleSpecification[] required = model.getBundleDescription().getRequiredBundles();
for (BundleSpecification element : required) {
if (!allBundleNames.contains(element.getName())) {
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java
index e269ccab46f..2b0bb42162b 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java
@@ -31,6 +31,7 @@
import javax.xml.parsers.DocumentBuilder;
import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.internal.runtime.XmlProcessorFactory;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -51,7 +52,6 @@
import org.eclipse.pde.internal.core.target.TargetDefinition;
import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper;
import org.eclipse.pde.internal.core.target.TargetPersistence38Helper;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.eclipse.pde.ui.tests.PDETestsPlugin;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -555,7 +555,7 @@ public void deserializationTest(IUBundleContainer location) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
TargetDefinitionPersistenceHelper.persistXML(td, out);
String xml = new String(out.toByteArray());
- DocumentBuilder parser = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
+ DocumentBuilder parser = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE();
parser.setErrorHandler(new DefaultHandler());
Document doc = parser.parse(new InputSource(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))));
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetEnvironmentTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetEnvironmentTestCase.java
index 52a57ae9a07..36aefd91867 100644
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetEnvironmentTestCase.java
+++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetEnvironmentTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2018 IBM Corporation and others.
+ * Copyright (c) 2006, 2023 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,21 +14,67 @@
package org.eclipse.pde.ui.tests.target;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.Arrays;
import java.util.Dictionary;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
-
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.pde.core.plugin.TargetPlatform;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
+import org.eclipse.pde.ui.tests.runtime.TestUtils;
+import org.eclipse.pde.ui.tests.util.ProjectUtils;
+import org.eclipse.pde.ui.tests.util.TargetPlatformUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
import org.junit.Test;
+import org.junit.rules.TestRule;
import org.osgi.framework.Constants;
public class TargetEnvironmentTestCase {
+
+ private static final String JAVA_SE_1_7 = "JavaSE-1.7";
+
+ @ClassRule
+ public static final TestRule RESTORE_TARGET_DEFINITION = TargetPlatformUtil.RESTORE_CURRENT_TARGET_DEFINITION_AFTER;
+ @ClassRule
+ public static final TestRule CLEAR_WORKSPACE = ProjectUtils.DELETE_ALL_WORKSPACE_PROJECTS_BEFORE_AND_AFTER;
+
+ @BeforeClass
+ public static void setupTargetPlatform() throws Exception {
+ TargetPlatformUtil.setRunningPlatformAsTarget();
+ }
+
+ private IExecutionEnvironment eeJava_1_7;
+ private IVMInstall eeJava_1_7DefaultVM;
+
+ @Before
+ public void saveJava1_7EEDefault() {
+ eeJava_1_7 = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(JAVA_SE_1_7);
+ eeJava_1_7DefaultVM = eeJava_1_7.getDefaultVM();
+ }
+
+ @After
+ public void restoreJava1_7EEDefault() {
+ eeJava_1_7.setDefaultVM(eeJava_1_7DefaultVM);
+ }
+
@Test
public void testOS() {
assertEquals(Platform.getOS(), TargetPlatform.getOS());
@@ -82,13 +128,12 @@ public void testDictionaryNL() {
@Test
public void testResolveOptional() {
Dictionary dictionary = TargetPlatformHelper.getTargetEnvironment();
- assertTrue("true".equals(dictionary.get("osgi.resolveOptional")));
+ assertEquals("true", dictionary.get("osgi.resolveOptional"));
}
/**
* Tests that the OSGi state for the PDE models has the correct properties set, based on known execution environments
*/
- @SuppressWarnings("deprecation")
@Test
public void testStateEEProperties() {
Dictionary, ?>[] platformProps = TargetPlatformHelper.getState().getPlatformProperties();
@@ -100,29 +145,22 @@ public void testStateEEProperties() {
Properties profileProps = environment.getProfileProperties();
if (profileProps != null) {
// If we have profile properties for an execution environment, ensure that they were added to the state
- String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
- if (systemPackages != null){
- boolean foundSystemPackage = false;
- for (Dictionary, ?> platformProp : platformProps) {
- if (systemPackages.equals(platformProp.get(Constants.FRAMEWORK_SYSTEMPACKAGES))){
- foundSystemPackage = true;
- break;
- }
- }
- if (!foundSystemPackage){
+ Set profileSystemPackages = getSystemPackages(profileProps)
+ .filter(p -> p.startsWith("java.")).collect(Collectors.toSet());
+ if (!profileSystemPackages.isEmpty()) {
+ String profileEE = getExecutionenvironment(profileProps);
+ boolean foundSystemPackage = Arrays.stream(platformProps)
+ .filter(pp -> profileEE.equals(getExecutionenvironment(pp))).anyMatch(pp -> {
+ Set packages = getSystemPackages(pp).collect(Collectors.toSet());
+ return packages.containsAll(profileSystemPackages);
+ });
+ if (!foundSystemPackage) {
fail("The system packages property for EE " + profile + " was not found in the state's propeties");
}
}
- String ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
- if (ee != null){
- boolean foundEE = false;
- for (Dictionary, ?> platformProp : platformProps) {
- if (ee.equals(platformProp.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT))){
- foundEE = true;
- break;
- }
- }
- if (!foundEE){
+ String ee = getExecutionenvironment(profileProps);
+ if (ee != null) {
+ if (Stream.of(platformProps).map(pp -> getExecutionenvironment(pp)).noneMatch(ee::equals)) {
fail("The framework EE property for EE " + profile + " was not found in the state's propeties");
}
}
@@ -131,4 +169,51 @@ public void testStateEEProperties() {
}
}
+ @SuppressWarnings("deprecation")
+ private String getExecutionenvironment(Object profile) {
+ return (String) ((Map, ?>) profile).get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
+ }
+
+ private static Stream getSystemPackages(Object profile) {
+ String platformPackages = (String) ((Map, ?>) profile).get(Constants.FRAMEWORK_SYSTEMPACKAGES);
+ if (platformPackages == null) {
+ return Stream.empty();
+ }
+ return Arrays.stream(platformPackages.split(","));
+ }
+
+ @Test
+ public void testProjectWithJVMImports() throws CoreException {
+ // A Java-1.7 VM does not provide the java.util.function package
+ // introduced in 1.8. But if we say that a Java 1.8+ VM the default
+ // (which the one running this test and thus the workspaces default-VM
+ // should be), well then the system-packages of that Java 1.8+ VM should
+ // be used in the PDEState and thus there should not be errors. This
+ // might not be a good idea in production, but is a good test-case.
+ IProject project = ProjectUtils.createPluginProject("foo.bar", "foo.bar", "1.0.0.qualifier", (d, s) -> {
+ d.setExecutionEnvironments(new String[] { JAVA_SE_1_7 });
+ d.setHeader(Constants.IMPORT_PACKAGE, "java.util.function");
+ d.setHeader("Automatic-Module-Name", "foo.bar");
+ });
+ project.build(IncrementalProjectBuilder.FULL_BUILD, null);
+ List errorsWithoutEEDefault = findErrorMarkers(project);
+ assertEquals(errorsWithoutEEDefault.toString(), 1, errorsWithoutEEDefault.size());
+
+ eeJava_1_7.setDefaultVM(JavaRuntime.getDefaultVMInstall());
+
+ // await at least VMInstall/EE change delay in
+ // MinimalState.rereadSystemPackagesAndReloadTP()
+ TestUtils.waitForJobs("testProjectWithEEImports", 300, 10_000);
+
+ List errorsWithEEDefault = findErrorMarkers(project);
+ assertEquals(List.of(), errorsWithEEDefault);
+ }
+
+ private List findErrorMarkers(IProject project) throws CoreException {
+ IMarker[] markers = project.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ List errorsWithoutEEDefault = Arrays.stream(markers)
+ .filter(m -> m.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR).toList();
+ return errorsWithoutEEDefault;
+ }
+
}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ALLXMLUtilTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ALLXMLUtilTests.java
deleted file mode 100644
index b1af49a22fa..00000000000
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ALLXMLUtilTests.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.ui.tests.util.xml;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@RunWith(Suite.class)
-@SuiteClasses({ ParserWrapperTestCase.class })
-public class ALLXMLUtilTests {
-
-}
diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java
deleted file mode 100644
index 62550c049bb..00000000000
--- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/util/xml/ParserWrapperTestCase.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.pde.ui.tests.util.xml;
-
-import static org.junit.Assert.assertFalse;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.pde.internal.core.XMLDefaultHandler;
-import org.eclipse.pde.internal.core.util.SAXParserWrapper;
-import org.eclipse.pde.ui.tests.PDETestsPlugin;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.xml.sax.SAXException;
-
-public class ParserWrapperTestCase {
-
- protected static final int FTHREADCOUNT = 5;
- protected static final int FSAX = 0;
- protected static final int FDOM = 1;
- protected static File fXMLFile;
- protected static final String FFILENAME = "/plugin.xml"; //$NON-NLS-1$
-
- @Before
- public void setUp() throws Exception {
- PDETestsPlugin plugin = PDETestsPlugin.getDefault();
- if (plugin == null)
- throw new Exception("ERROR: Macro plug-in uninitialized"); //$NON-NLS-1$
- Bundle bundle = plugin.getBundle();
- if (bundle == null)
- throw new Exception("ERROR: Bundle uninitialized"); //$NON-NLS-1$
- URL url = bundle.getEntry(FFILENAME);
- if (url == null)
- throw new Exception("ERROR: URL not found: " + FFILENAME); //$NON-NLS-1$
- String path = FileLocator.resolve(url).getPath();
- if ("".equals(path)) //$NON-NLS-1$
- throw new Exception("ERROR: URL unresolved: " + FFILENAME); //$NON-NLS-1$
- fXMLFile = new File(path);
- }
-
- @Test
- public void testSAXParserWrapperConcurrency() throws Exception {
-
- ParserThread[] threads = new ParserThread[FTHREADCOUNT];
-
- for (int x = 0; x < FTHREADCOUNT; x++) {
- threads[x] = new ParserThread(FSAX, fXMLFile);
- threads[x].start();
- }
-
- for (int x = 0; x < FTHREADCOUNT; x++) {
- threads[x].join();
- assertFalse(threads[x].getError());
- }
-
- }
-
- public static class ParserThread extends Thread {
-
- protected final int FITERATIONS = 100;
- protected File fParserXMLFile;
- protected boolean fError;
- protected int fParserType;
-
- public ParserThread(int parserType, File file) {
- fError = false;
- fParserType = parserType;
- fParserXMLFile = file;
- }
-
- @Override
- public void run() {
-
- if (fParserType == ParserWrapperTestCase.FSAX) {
- runSAX();
- }
- }
-
- public void runSAX() {
-
- for (int x = 0; x < FITERATIONS; x++) {
-
- try {
- XMLDefaultHandler handler = new XMLDefaultHandler();
- SAXParserWrapper.parse(fParserXMLFile, handler);
- } catch (ParserConfigurationException | SAXException | FactoryConfigurationError | IOException e) {
- e.printStackTrace();
- fError = true;
- }
- // If an error was encountered abort the thread
- // Any type of exception experienced is bad
- if (fError)
- return;
-
- }
-
- }
-
-
- public boolean getError() {
- return fError;
- }
-
- }
-
-}
diff --git a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
index f7693ec2fed..62c8423a3d4 100644
--- a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF
@@ -121,7 +121,9 @@ Require-Bundle:
biz.aQute.bndlib;bundle-version="6.3.1"
Import-Package: org.eclipse.jdt.debug.ui.console,
org.eclipse.ui.internal.genericeditor,
- org.osgi.service.event;version="[1.4,2.0.0)"
+ org.osgi.service.event;version="[1.4,2.0.0)",
+ org.osgi.service.repository;version="1.1.0",
+ org.osgi.util.promise;version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.pde.ui
diff --git a/ui/org.eclipse.pde.ui/icons/dview16/memory_view.png b/ui/org.eclipse.pde.ui/icons/dview16/memory_view.png
new file mode 100644
index 00000000000..0e09f99274c
Binary files /dev/null and b/ui/org.eclipse.pde.ui/icons/dview16/memory_view.png differ
diff --git a/ui/org.eclipse.pde.ui/icons/dview16/memory_view@2x.png b/ui/org.eclipse.pde.ui/icons/dview16/memory_view@2x.png
new file mode 100644
index 00000000000..28b9586940d
Binary files /dev/null and b/ui/org.eclipse.pde.ui/icons/dview16/memory_view@2x.png differ
diff --git a/ui/org.eclipse.pde.ui/plugin.properties b/ui/org.eclipse.pde.ui/plugin.properties
index 68fe8219459..f2465f6d2e1 100644
--- a/ui/org.eclipse.pde.ui/plugin.properties
+++ b/ui/org.eclipse.pde.ui/plugin.properties
@@ -301,6 +301,8 @@ projectConfigurator.label.bundle = Eclipse Plugin/OSGi Bundle
projectConfigurator.label.feature = Eclipse Feature
create.module.info.label.pde= Create module-info.java
+locationProvider.reference.name = Target File
+locationProvider.reference.description = Add a reference to another target file
-locationProvider.description = Add a reference to another target file
-locationProvider.name = Target File
+locationProvider.repository.name = OSGi Repository
+locationProvider.repository.description = Add content from an OSGi Repository according to the Repository Service Specification
diff --git a/ui/org.eclipse.pde.ui/plugin.xml b/ui/org.eclipse.pde.ui/plugin.xml
index 0e07dae58dc..a30d3ad863a 100644
--- a/ui/org.eclipse.pde.ui/plugin.xml
+++ b/ui/org.eclipse.pde.ui/plugin.xml
@@ -2230,6 +2230,32 @@
type="org.eclipse.jface.viewers.ITreeContentProvider">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2246,9 +2272,18 @@
class="org.eclipse.pde.internal.ui.shared.target.TargetReferenceLocationWizard"
icon="icons/obj16/target_profile_xml_obj.png"
id="org.eclipse.pde.ui.TargetReferenceProvisioner"
- name="%locationProvider.name">
+ name="%locationProvider.reference.name">
+
+ %locationProvider.reference.description
+
+
+
- %locationProvider.description
+ %locationProvider.repository.description
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java
index b9d12d6edca..4430ef44e8e 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPlugin.java
@@ -28,6 +28,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.pde.internal.core.PDEPreferencesManager;
import org.eclipse.pde.internal.ui.launcher.PDELogFileProvider;
+import org.eclipse.pde.internal.ui.shared.target.RepositoryBundleContainerAdapterFactory;
import org.eclipse.pde.internal.ui.shared.target.TargetReferenceBundleContainerAdapterFactory;
import org.eclipse.pde.internal.ui.shared.target.TargetStatus;
import org.eclipse.pde.internal.ui.util.SWTUtil;
@@ -233,6 +234,7 @@ public void stop(BundleContext context) throws Exception {
Utilities.shutdown();
super.stop(context);
TargetReferenceBundleContainerAdapterFactory.LABEL_PROVIDER.dispose();
+ RepositoryBundleContainerAdapterFactory.LABEL_PROVIDER.dispose();
}
public PDELabelProvider getLabelProvider() {
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java
index 289bf3aabc4..265f889b230 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java
@@ -42,6 +42,7 @@ public class PDEPluginImages {
private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$
private static final String PATH_VIEW = ICONS_PATH + "view16/"; //$NON-NLS-1$
+ private static final String PATH_DVIEW = ICONS_PATH + "dview16/"; //$NON-NLS-1$
private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$
private static final String PATH_LCL_DISABLED = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$
private static final String PATH_TOOL = ICONS_PATH + "etool16/"; //$NON-NLS-1$
@@ -316,6 +317,7 @@ public class PDEPluginImages {
* View
*/
public static final ImageDescriptor DESC_ARGUMENT_TAB = create(PATH_VIEW, "variable_tab.png"); //$NON-NLS-1$
+ public static final ImageDescriptor DESC_TARGET_REPO = create(PATH_DVIEW, "memory_view.png"); //$NON-NLS-1$
private static ImageDescriptor create(String prefix, String name) {
return ImageDescriptor.createFromURL(makeImageURL(prefix, name));
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndModel.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndModel.java
index 7e0b45d16a4..a4d99774b04 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndModel.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/bnd/BndModel.java
@@ -20,6 +20,7 @@
import org.eclipse.pde.core.IModelChangeProvider;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.core.IModelChangedListener;
+import org.eclipse.pde.internal.core.bnd.BndDocument;
import aQute.bnd.build.model.BndEditModel;
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditRepositoryContainerPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditRepositoryContainerPage.java
new file mode 100644
index 00000000000..667d4d516a1
--- /dev/null
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditRepositoryContainerPage.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2023 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Christoph Läubrich - Bug 577184 - [target] Allow references to other targets inside a target-file
+ * Christoph Läubrich - add support for repositories
+ *******************************************************************************/
+package org.eclipse.pde.internal.ui.shared.target;
+
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.ui.StringVariableSelectionDialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.internal.core.target.RemoteTargetHandle;
+import org.eclipse.pde.internal.core.target.RepositoryBundleContainer;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.SWTFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Wizard page for creating a new directory bundle container.
+ *
+ * @see AddBundleContainerWizard
+ * @see AddBundleContainerSelectionPage
+ * @see ITargetLocation
+ */
+public class EditRepositoryContainerPage extends WizardPage implements IEditBundleContainerPage {
+
+ /**
+ * How long to wait before validating the directory
+ */
+ protected static final int TYPING_DELAY = 200;
+
+ protected Combo furiLocation;
+ protected RepositoryBundleContainer fContainer;
+
+ /**
+ * Dialog settings key for the most recent location
+ */
+ private static final String SETTINGS_LOCATION_1 = "location1"; //$NON-NLS-1$
+
+ /**
+ * Dialog settings key for the second most recent location
+ */
+ private static final String SETTINGS_LOCATION_2 = "location2"; //$NON-NLS-1$
+
+ /**
+ * Dialog settings key for the third most recent location
+ */
+ private static final String SETTINGS_LOCATION_3 = "location3"; //$NON-NLS-1$
+
+ public EditRepositoryContainerPage(RepositoryBundleContainer bundleContainer) {
+ super("EditRepositoryContainerPage"); //$NON-NLS-1$
+ fContainer = bundleContainer;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ setMessage(getDefaultMessage());
+ setTitle(getDefaultTitle());
+ setPageComplete(false);
+ Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
+ createLocationArea(comp);
+ setControl(comp);
+ initializeInputFields(fContainer);
+ }
+
+ /**
+ * @return the default title for this wizard page
+ */
+ protected String getDefaultTitle() {
+ if (fContainer == null) {
+ return Messages.EditRepositoryContainerPage_Add_Title;
+ }
+ return Messages.EditRepositoryContainerPage_Edit_Title;
+ }
+
+ /**
+ * @return the default message for this wizard page
+ */
+ protected String getDefaultMessage() {
+ return Messages.EditRepositoryContainerPage_Message;
+ }
+
+ /**
+ * Creates the area at the top of the page. Contains an entry form for a
+ * location path. This method may be overridden by subclasses to provide
+ * custom widgets
+ *
+ * @param parent
+ * parent composite
+ */
+ protected void createLocationArea(Composite parent) {
+ Composite locationComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
+
+ SWTFactory.createLabel(locationComp, Messages.AddDirectoryContainerPage_2, 1);
+
+ furiLocation = SWTFactory.createCombo(locationComp, SWT.BORDER, 1, getLocationComboItems());
+ furiLocation.addModifyListener(e -> {
+ setPageComplete(validateInput());
+ });
+ try {
+ String location = fContainer != null ? fContainer.getLocation(false) : ""; //$NON-NLS-1$
+ furiLocation.setText(location);
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ }
+
+ Composite buttonComp = SWTFactory.createComposite(locationComp, 2, 2, GridData.CENTER, 0, 0);
+ GridData gd = (GridData) buttonComp.getLayoutData();
+ gd.horizontalAlignment = SWT.RIGHT;
+
+ Button variablesButton = SWTFactory.createPushButton(buttonComp, Messages.EditDirectoryContainerPage_1, null);
+ variablesButton.addSelectionListener(widgetSelectedAdapter(e -> {
+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
+ dialog.open();
+ String variable = dialog.getVariableExpression();
+ if (variable != null) {
+ furiLocation.setText(furiLocation.getText() + variable);
+ }
+ }));
+ }
+
+ /**
+ * Initializes the fields use to describe the container. They should be
+ * filled in using the given container or set to default values if the
+ * container is null
.
+ *
+ * @param container
+ * bundle container being edited, possibly null
+ */
+ protected void initializeInputFields(ITargetLocation container) {
+ try {
+ String currentLocation = fContainer != null ? fContainer.getLocation(false) : ""; //$NON-NLS-1$
+ boolean found = false;
+ String[] items = furiLocation.getItems();
+ for (String item : items) {
+ if (item.equals(currentLocation)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ furiLocation.add(currentLocation);
+ }
+ furiLocation.setText(currentLocation);
+
+ setPageComplete(validateInput());
+ } catch (CoreException e) {
+ PDEPlugin.log(e);
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return !furiLocation.getText().isBlank();
+ }
+
+ /**
+ * @return a list of previous locations from settings plus the default
+ * location
+ */
+ private String[] getLocationComboItems() {
+ List previousLocations = new ArrayList<>(4);
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ String location = settings.get(SETTINGS_LOCATION_1);
+ if (location != null) {
+ previousLocations.add(location);
+ }
+ location = settings.get(SETTINGS_LOCATION_2);
+ if (location != null) {
+ previousLocations.add(location);
+ }
+ location = settings.get(SETTINGS_LOCATION_3);
+ if (location != null) {
+ previousLocations.add(location);
+ }
+ }
+ return previousLocations.toArray(new String[previousLocations.size()]);
+ }
+
+ @Override
+ public void storeSettings() {
+ String newLocation = furiLocation.getText().trim();
+
+ int length = newLocation.length();
+ if (length > 0 && newLocation.charAt(length - 1) == File.separatorChar) {
+ newLocation = newLocation.substring(0, length - 1);
+ }
+ String[] items = furiLocation.getItems();
+ for (String item : items) {
+ if (item.equals(newLocation)) {
+ // Already have this location stored
+ return;
+ }
+ }
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ String location = settings.get(SETTINGS_LOCATION_2);
+ if (location != null) {
+ settings.put(SETTINGS_LOCATION_3, location);
+ }
+ location = settings.get(SETTINGS_LOCATION_1);
+ if (location != null) {
+ settings.put(SETTINGS_LOCATION_2, location);
+ }
+ settings.put(SETTINGS_LOCATION_1, newLocation);
+ }
+ }
+
+ @Override
+ public RepositoryBundleContainer getBundleContainer() {
+ String rawUri = furiLocation != null & !furiLocation.isDisposed() ? furiLocation.getText().trim() : ""; //$NON-NLS-1$
+ return new RepositoryBundleContainer(rawUri, fContainer == null ? List.of() : fContainer.getRequirements());
+ }
+
+ /**
+ * Validate the input fields before a container is created/edited. The
+ * page's enablement, message and completion should be updated.
+ *
+ * @return whether the finish button should be enabled and container
+ * creation should continue
+ */
+ protected boolean validateInput() {
+ if (furiLocation.isDisposed())
+ return false;
+
+ // Check if the text field is blank
+ if (furiLocation.getText().trim().length() == 0) {
+ setMessage(getDefaultMessage());
+ return false;
+ }
+
+ // Resolve any variables
+ URI location;
+ try {
+ location = RemoteTargetHandle.getEffectiveUri(furiLocation.getText().trim());
+ } catch (CoreException e) {
+ setMessage(e.getMessage(), IMessageProvider.WARNING);
+ return true;
+ } catch (URISyntaxException e) {
+ setMessage(e.getMessage(), IMessageProvider.ERROR);
+ return false;
+ }
+ try {
+ // and be converted to an URL
+ URL url = location.toURL();
+ if ("file".equalsIgnoreCase(url.getProtocol())) { //$NON-NLS-1$
+ File file = new File(location);
+ if (!file.isFile()) {
+ setMessage(NLS.bind(Messages.EditTargetContainerPage_Not_A_File, file.getAbsolutePath()),
+ IMessageProvider.ERROR);
+ return true;
+ }
+ }
+ } catch (MalformedURLException | RuntimeException e) {
+ setMessage(e.getMessage(), IMessageProvider.ERROR);
+ return false;
+ }
+ setMessage(getDefaultMessage());
+ return true;
+ }
+
+}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java
index 7e44530752b..68fe25980ec 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java
@@ -152,6 +152,11 @@ public class Messages extends NLS {
public static String EditTargetContainerPage_Edit_Title;
public static String EditTargetContainerPage_Message;
public static String EditTargetContainerPage_Not_A_File;
+ public static String EditRepositoryContainerPage_Message;
+ public static String EditRepositoryContainerPage_Add_Title;
+ public static String EditRepositoryContainerPage_Edit_Title;
+ public static String SelectRepositoryContentPage_Title;
+ public static String SelectRepositoryContentPage_Description;
static {
// initialize resource bundle
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/RepositoryBundleContainerAdapterFactory.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/RepositoryBundleContainerAdapterFactory.java
new file mode 100644
index 00000000000..46e804f28eb
--- /dev/null
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/RepositoryBundleContainerAdapterFactory.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2023 Christoph Läubrich and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christoph Läubrich - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.ui.shared.target;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.internal.core.target.RepositoryBundleContainer;
+import org.eclipse.pde.internal.launching.IPDEConstants;
+import org.eclipse.pde.internal.ui.PDEPluginImages;
+import org.eclipse.pde.ui.target.ITargetLocationHandler;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.resource.Requirement;
+
+public class RepositoryBundleContainerAdapterFactory implements IAdapterFactory {
+
+ private static final Object[] EMPTY_OBJECTS = new Object[0];
+
+ public static final ILabelProvider LABEL_PROVIDER = new LabelProvider() {
+
+ private Image repositoryImage;
+ private Image requirementImage;
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof RepositoryBundleContainer container) {
+ try {
+ return container.getLocation(true);
+ } catch (CoreException e) {
+ return container.getUri();
+ }
+ }
+ if (element instanceof RequirementNode requirement) {
+ return requirement.requirement().toString();
+ }
+ return null;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof RepositoryBundleContainer) {
+ if (repositoryImage == null) {
+ repositoryImage = PDEPluginImages.DESC_TARGET_REPO.createImage();
+ }
+ return repositoryImage;
+ }
+ if (element instanceof RequirementNode) {
+ if (requirementImage == null) {
+ requirementImage = PDEPluginImages.DESC_FILTER.createImage();
+ }
+ return requirementImage;
+ }
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (repositoryImage != null) {
+ repositoryImage.dispose();
+ repositoryImage = null;
+ }
+ }
+ };
+
+ private static final ITargetLocationHandler LOCATION_HANDLER = new ITargetLocationHandler() {
+
+ @Override
+ public IStatus reload(ITargetDefinition target, ITargetLocation[] targetLocations, IProgressMonitor monitor) {
+ for (ITargetLocation location : targetLocations) {
+ if (location instanceof RepositoryBundleContainer container) {
+ container.reload();
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ public IWizard getEditWizard(ITargetDefinition target, TreePath treePath) {
+ Object segment = treePath.getLastSegment();
+ if (segment instanceof RequirementNode node) {
+ // TODO maybe we can support a requirements editor?
+ segment = node.container;
+ }
+ if (segment instanceof RepositoryBundleContainer container) {
+ RepositoryLocationWizard wizard = new RepositoryLocationWizard();
+ wizard.setTarget(target);
+ wizard.setBundleContainer(container);
+ return wizard;
+ }
+ return null;
+ }
+
+ @Override
+ public boolean canEdit(ITargetDefinition target, TreePath treePath) {
+ Object segment = treePath.getLastSegment();
+ return segment instanceof RepositoryBundleContainer || segment instanceof RequirementNode;
+ }
+
+ public boolean canRemove(ITargetDefinition target, TreePath treePath) {
+ return treePath.getLastSegment() instanceof RequirementNode;
+ }
+
+ public IStatus remove(ITargetDefinition target, TreePath[] treePaths) {
+ boolean reload = false;
+ for (TreePath path : treePaths) {
+ Object lastSegment = path.getLastSegment();
+ if (lastSegment instanceof RequirementNode node) {
+ RepositoryBundleContainer container = node.container;
+ RepositoryBundleContainer newContainer = new RepositoryBundleContainer(container.getUri(),
+ container.getRequirements().stream().filter(req -> req != node.requirement()).toList());
+ ITargetLocation[] targetLocations = target.getTargetLocations();
+ for (int i = 0; i < targetLocations.length; i++) {
+ ITargetLocation loc = targetLocations[i];
+ if (loc == container) {
+ targetLocations[i] = newContainer;
+ }
+
+ }
+ }
+ }
+ return reload
+ ? new Status(IStatus.OK, IPDEConstants.UI_PLUGIN_ID, ITargetLocationHandler.STATUS_FORCE_RELOAD,
+ "reloaded", null) //$NON-NLS-1$
+ : Status.OK_STATUS;
+ }
+ };
+
+ private static final ITreeContentProvider TREE_CONTENT_PROVIDER = new ITreeContentProvider() {
+
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof RepositoryBundleContainer container) {
+ return !container.getRequirements().isEmpty();
+ }
+ return false;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof RequirementNode node) {
+ return node.container;
+ }
+ return null;
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return EMPTY_OBJECTS; // will never be called...
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof RepositoryBundleContainer container) {
+ return container.getRequirements().stream().map(req -> new RequirementNode(req, container)).toArray();
+ }
+ return EMPTY_OBJECTS;
+ }
+ };
+
+ @Override
+ public T getAdapter(Object adaptableObject, Class adapterType) {
+ if (adaptableObject instanceof RepositoryBundleContainer
+ || adaptableObject instanceof RequirementNode) {
+ if (adapterType == ILabelProvider.class) {
+ return adapterType.cast(LABEL_PROVIDER);
+ }
+ if (adapterType == ITargetLocationHandler.class) {
+ return adapterType.cast(LOCATION_HANDLER);
+ }
+ if (adapterType == ITreeContentProvider.class) {
+ return adapterType.cast(TREE_CONTENT_PROVIDER);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Class>[] getAdapterList() {
+ return new Class>[] { ILabelProvider.class, ITargetLocationHandler.class, ITreeContentProvider.class };
+ }
+
+ /**
+ * Simple wrapper class to identify it uniquly when adaption take place and
+ * to record the parent
+ */
+ public static final record RequirementNode(Requirement requirement, RepositoryBundleContainer container) {
+
+ }
+
+
+}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/RepositoryLocationWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/RepositoryLocationWizard.java
new file mode 100644
index 00000000000..65018a8083e
--- /dev/null
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/RepositoryLocationWizard.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2023 Christoph Läubrich and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christoph Läubrich - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.ui.shared.target;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.pde.core.target.ITargetDefinition;
+import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.internal.core.target.RepositoryBundleContainer;
+import org.eclipse.pde.ui.target.ITargetLocationWizard;
+
+public class RepositoryLocationWizard extends Wizard implements ITargetLocationWizard {
+
+ private EditRepositoryContainerPage repositoryPage;
+ private ITargetLocation wizardLocation;
+ private ITargetDefinition target;
+ private RepositoryBundleContainer bundleContainer;
+ private SelectRepositoryContentPage selectionPage;
+
+ public RepositoryLocationWizard() {
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public void setTarget(ITargetDefinition target) {
+ this.target = target;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(repositoryPage = new EditRepositoryContainerPage(bundleContainer));
+ addPage(selectionPage = new SelectRepositoryContentPage(repositoryPage));
+
+ setWindowTitle(repositoryPage.getDefaultTitle());
+ }
+
+ @Override
+ public ITargetLocation[] getLocations() {
+ if (wizardLocation == null) {
+ return new ITargetLocation[0];
+ }
+ return new ITargetLocation[] { wizardLocation };
+ }
+
+ @Override
+ public boolean performFinish() {
+ wizardLocation = selectionPage.getBundleContainer();
+ if (target != null && bundleContainer != null) {
+ ITargetLocation[] locations = target.getTargetLocations();
+ for (int i = 0; i < locations.length; i++) {
+ ITargetLocation location = locations[i];
+ if (location == bundleContainer) {
+ locations[i] = wizardLocation;
+ }
+ }
+ target.setTargetLocations(locations);
+ }
+ return true;
+ }
+
+ public void setBundleContainer(RepositoryBundleContainer bundleContainer) {
+ this.bundleContainer = bundleContainer;
+ }
+
+}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/SelectRepositoryContentPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/SelectRepositoryContentPage.java
new file mode 100644
index 00000000000..c1646697a0f
--- /dev/null
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/SelectRepositoryContentPage.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2023 Christoph Läubrich and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christoph Läubrich - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.ui.shared.target;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.pde.core.target.ITargetLocation;
+import org.eclipse.pde.internal.core.target.RepositoryBundleContainer;
+import org.eclipse.pde.internal.ui.PDEPluginImages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+
+import aQute.bnd.osgi.repository.ResourcesRepository;
+import aQute.bnd.osgi.resource.CapReqBuilder;
+import aQute.bnd.osgi.resource.ResourceUtils;
+import aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability;
+
+public class SelectRepositoryContentPage extends WizardPage implements IEditBundleContainerPage {
+
+ private EditRepositoryContainerPage repositoryPage;
+ private String lastLocation;
+ private CheckboxTableViewer viewer;
+ private Collection requirements;
+ private Set selected = ConcurrentHashMap.newKeySet();
+
+ protected SelectRepositoryContentPage(EditRepositoryContainerPage repositoryPage) {
+ super("SelectRepositoryContentPage"); //$NON-NLS-1$
+ this.repositoryPage = repositoryPage;
+ setTitle(Messages.SelectRepositoryContentPage_Title);
+ setDescription(Messages.SelectRepositoryContentPage_Description);
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ if (visible) {
+ try {
+ RepositoryBundleContainer container = repositoryPage.getBundleContainer();
+ if (requirements == null) {
+ // only init the requirements once...
+ requirements = new HashSet<>(container.getRequirements());
+ }
+ String location = container.getLocation(true);
+ if (lastLocation != location) {
+ // Load the repository!!
+ getContainer().run(true, true, monitor -> {
+ try {
+ ResourcesRepository repository = container.getRepository(monitor);
+ selected.clear();
+ List resources = repository.getResources();
+ repository.findProviders(requirements).values().stream().flatMap(Collection::stream)
+ .map(Capability::getResource).distinct().forEach(selected::add);
+ if (viewer != null) {
+ viewer.getControl().getDisplay().execute(() -> {
+ if (viewer.getControl().isDisposed()) {
+ return;
+ }
+ viewer.setInput(resources);
+ });
+ }
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ });
+ }
+ setErrorMessage(null);
+ } catch (CoreException e) {
+ setErrorMessage(e.getStatus().getMessage());
+ } catch (InvocationTargetException e) {
+ setErrorMessage(e.getMessage());
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ super.setVisible(visible);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+
+ viewer = CheckboxTableViewer.newCheckList(parent, SWT.NONE);
+ viewer.setCheckStateProvider(new ICheckStateProvider() {
+
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
+
+ @Override
+ public boolean isChecked(Object element) {
+ if (element instanceof Resource resource) {
+ return selected.contains(resource);
+ }
+ return false;
+ }
+ });
+ viewer.setContentProvider(ArrayContentProvider.getInstance());
+ viewer.setLabelProvider(new LabelProvider() {
+ private Image pluginImage;
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof Resource resource) {
+ return resource.toString();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof Resource resource) {
+ if (ResourceUtils.getBundleCapability(resource) != null) {
+ if (pluginImage == null) {
+ pluginImage = PDEPluginImages.DESC_PLUGIN_OBJ.createImage();
+ viewer.getControl().addDisposeListener(e -> pluginImage.dispose());
+ }
+ return pluginImage;
+ }
+ }
+ return null;
+ }
+ });
+ viewer.addCheckStateListener(new ICheckStateListener() {
+
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ Object element = event.getElement();
+ if (element instanceof Resource resource) {
+ Requirement requirement = getRequirement(resource);
+ if (requirement != null) {
+ if (event.getChecked()) {
+ selected.add(resource);
+ requirements.add(requirement);
+ } else {
+ selected.remove(resource);
+ requirements.remove(requirement);
+ }
+ }
+ }
+ }
+ });
+ setControl(viewer.getControl());
+ }
+
+ protected Requirement getRequirement(Resource resource) {
+ IdentityCapability identity = ResourceUtils.getIdentityCapability(resource);
+ String v = identity.version().toString();
+ return CapReqBuilder.createSimpleRequirement(identity.getNamespace(), identity.osgi_identity(),
+ String.format("[%s,%s]", v, v)) //$NON-NLS-1$
+ .setResource(resource).buildRequirement();
+ }
+
+ @Override
+ public ITargetLocation getBundleContainer() {
+ RepositoryBundleContainer container = repositoryPage.getBundleContainer();
+ return new RepositoryBundleContainer(container.getUri(),
+ requirements == null ? container.getRequirements() : List.copyOf(requirements));
+ }
+
+ @Override
+ public void storeSettings() {
+
+ }
+
+}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties
index 83a8650ae7e..84a8f4dee47 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties
@@ -143,5 +143,10 @@ UpdateTargetJob_UpdateJobName=Update Target Definition
UpdateTargetJob_UpdatingTarget=Updating Target
EditTargetContainerPage_Add_Title=Create target reference
EditTargetContainerPage_Edit_Title=Edit target reference
-EditTargetContainerPage_Message=Please enter an URI to the target to be referenced
-EditTargetContainerPage_Not_A_File={0} is not a file
\ No newline at end of file
+EditTargetContainerPage_Message=Please enter a URI to the target to be referenced
+EditTargetContainerPage_Not_A_File={0} is not a file
+EditRepositoryContainerPage_Message=Please enter a URI that points to the repository
+EditRepositoryContainerPage_Add_Title=Create OSGi Repository Location
+EditRepositoryContainerPage_Edit_Title=Edit OSGi Repository Location
+SelectRepositoryContentPage_Title=Select Content
+SelectRepositoryContentPage_Description=Select the content that should be included in this location
\ No newline at end of file
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java
index 43b0d00f125..046b8d91f6f 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java
@@ -28,7 +28,6 @@
import org.eclipse.pde.internal.core.exports.FeatureExportInfo;
import org.eclipse.pde.internal.core.exports.FeatureExportOperation;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.eclipse.pde.internal.ui.PDEPluginImages;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.build.RuntimeInstallJob;
@@ -133,7 +132,8 @@ public void done(IJobChangeEvent event) {
@Override
protected Document generateAntTask() {
try {
- Document doc = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE().newDocument();
+ @SuppressWarnings("restriction")
+ Document doc = org.eclipse.core.internal.runtime.XmlProcessorFactory.newDocumentWithErrorOnDOCTYPE();
Element root = doc.createElement("project"); //$NON-NLS-1$
root.setAttribute("name", "build"); //$NON-NLS-1$ //$NON-NLS-2$
root.setAttribute("default", "feature_export"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java
index c0af2883246..b8ae7411b8d 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java
@@ -24,7 +24,6 @@
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.exports.FeatureExportInfo;
import org.eclipse.pde.internal.core.exports.PluginExportOperation;
-import org.eclipse.pde.internal.core.util.PDEXmlProcessorFactory;
import org.eclipse.pde.internal.ui.PDEPluginImages;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.build.RuntimeInstallJob;
@@ -103,7 +102,8 @@ public void done(IJobChangeEvent event) {
@Override
protected Document generateAntTask() {
try {
- Document doc = PDEXmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE().newDocument();
+ @SuppressWarnings("restriction")
+ Document doc = org.eclipse.core.internal.runtime.XmlProcessorFactory.newDocumentWithErrorOnDOCTYPE();
Element root = doc.createElement("project"); //$NON-NLS-1$
root.setAttribute("name", "build"); //$NON-NLS-1$ //$NON-NLS-2$
root.setAttribute("default", "plugin_export"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/ui/org.eclipse.pde/pom.xml b/ui/org.eclipse.pde/pom.xml
index e227b31961d..02b6157e213 100644
--- a/ui/org.eclipse.pde/pom.xml
+++ b/ui/org.eclipse.pde/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
../../
org.eclipse.pde
diff --git a/ui/pom.xml b/ui/pom.xml
index 9cf8b3633c3..f1e59ea1662 100644
--- a/ui/pom.xml
+++ b/ui/pom.xml
@@ -14,7 +14,7 @@
org.eclipse.pde
eclipse.pde
- 4.29.0-SNAPSHOT
+ 4.30.0-SNAPSHOT
eclipse.pde.ui
pom