Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bundle
Bundle-SymbolicName: java25.bundle
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-25
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin.includes = META-INF/
15 changes: 15 additions & 0 deletions tycho-its/projects/eeProfile.java25/bundle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>tycho-its-project.eeProfile.java25</groupId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>parent</artifactId>
</parent>

<artifactId>java25.bundle</artifactId>
<packaging>eclipse-plugin</packaging>

</project>
33 changes: 33 additions & 0 deletions tycho-its/projects/eeProfile.java25/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>tycho-its-project.eeProfile.java25</groupId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>parent</artifactId>
<packaging>pom</packaging>

<modules>
<module>bundle</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<compilerId>javac</compilerId>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2025 Contributors 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:
* Contributors - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.test.eeProfile;

import static org.junit.Assert.assertTrue;

import java.io.File;

import org.apache.maven.it.Verifier;
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
import org.junit.Ignore;
import org.junit.Test;

@Ignore("unless java 25 jvm is available to tycho build")
public class Java25ResolutionTest extends AbstractTychoIntegrationTest {

@Test
public void testBundleBuildForJava25() throws Exception {
// Test that a bundle with JavaSE-25 BREE can be built with javac compiler
Verifier verifier = getVerifier("eeProfile.java25", false);
verifier.executeGoal("verify");
verifier.verifyErrorFreeLog();
verifier.verifyTextInLog("Building jar:");
File buildResult = new File(verifier.getBasedir());
File bundleJar = new File(buildResult, "bundle/target/java25.bundle-1.0.0-SNAPSHOT.jar");
assertTrue("Bundle JAR should exist", bundleJar.exists());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ private void enhanceReqCap(Attributes mainAttributes, Attributes calcAttributes)
String existingValue = mainAttributes.getValue(Constants.REQUIRE_CAPABILITY);
String newValue = calcAttributes.getValue(Constants.REQUIRE_CAPABILITY);
if (newValue != null) {
// Fix for JavaSE-25 and future Java versions not recognized by bndlib
// Bnd's Analyzer may generate osgi.ee=UNKNOWN for unrecognized BREE values
// We need to detect and fix this before it gets into the manifest
// See https://github.com/bndtools/bnd/issues/6858
if (newValue.contains("UNKNOWN")) {
String breeHeader = mainAttributes.getValue(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT);
if (breeHeader != null && !breeHeader.isEmpty()) {
String fixedFilter = convertBreeToOsgiEeFilter(breeHeader);
if (fixedFilter != null) {
// Replace the UNKNOWN filter with the correct one
newValue = newValue.replaceAll("osgi\\.ee;\\s*filter:=\"[^\"]*UNKNOWN[^\"]*\"",
"osgi.ee;filter:=\"" + fixedFilter + "\"");
logger.debug("Fixed UNKNOWN osgi.ee filter to: " + fixedFilter);
}
}
}

Parameters additional = OSGiHeader.parseHeader(newValue);
if (additional.containsKey(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE)) {
// remove deprecated header but use the ee namespace
Expand Down Expand Up @@ -164,4 +181,47 @@ private void enhanceReqCap(Attributes mainAttributes, Attributes calcAttributes)
}
}

/**
* Converts a Bundle-RequiredExecutionEnvironment (BREE) value to an osgi.ee filter.
* This is a workaround for bndlib not recognizing newer Java versions (like JavaSE-25).
*
* @param breeHeader the BREE header value (e.g., "JavaSE-25" or "JavaSE-17,JavaSE-25")
* @return an osgi.ee filter string, or null if the BREE cannot be parsed
*/
private String convertBreeToOsgiEeFilter(String breeHeader) {
// BREE can contain multiple comma-separated values, we need to pick the highest version
String[] brees = breeHeader.split(",");
int highestVersion = -1;

for (String bree : brees) {
bree = bree.trim();
// Parse JavaSE-XX or J2SE-XX format
if (bree.startsWith("JavaSE-") || bree.startsWith("J2SE-")) {
try {
String prefix = bree.startsWith("JavaSE-") ? "JavaSE-" : "J2SE-";
String versionStr = bree.substring(prefix.length());
// Remove "1." prefix if present (e.g., "1.8" -> "8")
if (versionStr.startsWith("1.")) {
versionStr = versionStr.substring(2);
}
int version = Integer.parseInt(versionStr);
if (version > highestVersion) {
highestVersion = version;
}
} catch (NumberFormatException e) {
// Ignore malformed BREE entries
}
}
}

if (highestVersion > 0) {
// Convert to osgi.ee filter format: (&(osgi.ee=JavaSE)(version=XX))
// Note: J2SE is mapped to JavaSE for the filter
return "(&(osgi.ee=JavaSE)(version=" + highestVersion + "))";
}

return null;
}

}