Skip to content

Add generic BREE support for modern Java versions and reject invalid BREEs#163

Draft
Copilot wants to merge 6 commits intomasterfrom
copilot/add-generic-bree-support
Draft

Add generic BREE support for modern Java versions and reject invalid BREEs#163
Copilot wants to merge 6 commits intomasterfrom
copilot/add-generic-bree-support

Conversation

Copy link

Copilot AI commented Oct 26, 2025

The BREE parsing in BundleDescriptionBuilder already handles modern Java versions generically via OSGi Version.parseVersion(), which accepts both dotted versions (1.8) and simple integers (25). This PR adds documentation, validation, and tests to clarify this behavior, ensure forward compatibility, and prevent invalid BREE values.

Changes

Documentation (BundleDescriptionBuilder.java)

  • Added Javadoc to getOSGiEENameVersion explaining support for legacy (J2SE-1.4), dotted (JavaSE-1.8), and modern (JavaSE-11, 17, 21, 25+) BREE formats
  • Added Javadoc to createOSGiEERequirementFilter showing OSGi filter generation for modern versions
  • Clarified that simple integer versions are automatically valid OSGi versions (e.g., "25" → "25.0.0")

Validation (BundleDescriptionBuilder.java)

  • Added validation in createOSGiEERequirementFilter to reject invalid BREEs like "UNKNOWN" or "UNSPECIFIED"
  • Improved error messages to help identify malformed BREE values
  • Prevents silent creation of invalid osgi.ee=UNKNOWN requirements as reported in Tycho fails to resolve JavaSE-25 eclipse-tycho/tycho#5446

Test Coverage (BundlesActionTest.java)

  • Added testJavaSE25BREE() and testJavaSE21BREE() for modern versions
  • Added testVariousJavaSEBREEFormats() covering JavaSE-11/17/21/25/1.8 and J2SE-1.4
  • Added testFutureJavaVersionBREEs() verifying JavaSE-30/50/100 forward compatibility
  • Added testInvalidBREEsRejected() to verify invalid BREEs like "UNKNOWN" are properly rejected
  • Created test bundles (test6, test7) with JavaSE-25 and JavaSE-21 BREEs

Examples

Valid BREE: A bundle with Bundle-RequiredExecutionEnvironment: JavaSE-25 generates the OSGi filter:

(&(osgi.ee=JavaSE)(version=25))

Invalid BREE: A bundle with an invalid BREE like UNKNOWN will now throw a clear error:

Invalid execution environment: 'UNKNOWN'. Expected format like 'JavaSE-11' or 'JavaSE-1.8'.

This prevents the creation of invalid requirements like osgi.ee=UNKNOWN and ensures bundles fail fast with clear error messages during publishing rather than causing cryptic resolution failures later.

Original prompt

Add generic support for BREEs

In eclipse-tycho/tycho#5533 it was claimed that The Statefactory currently does not support JavaSE-25 as a BREE as there is no profile and returns UNKOWN instead.

As these days we can assume that JavaSE- is the default anyways we should make this more generic to not return bad defaults and and testcases that check different szenarios with BundlesAction (what internally calls the statefactory)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits October 26, 2025 05:12
Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add generic support for BREEs in Statefactory Add generic BREE support for modern Java versions (JavaSE-25+) Oct 26, 2025
Copilot AI requested a review from laeubi October 26, 2025 05:23
@laeubi
Copy link
Owner

laeubi commented Oct 26, 2025

@copilot please investigate what can be the reason that we get UNKOWN as an EE as indicated in eclipse-tycho/tycho#5446 where we see the error

Missing requirement: org.eclipse.shellwax.core 1.4.0.20251009-1048 requires 'osgi.ee; (osgi.ee=UNKNOWN)' but it could not be found

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copy link
Author

Copilot AI commented Oct 26, 2025

@copilot please investigate what can be the reason that we get UNKOWN as an EE as indicated in eclipse-tycho/tycho#5446 where we see the error

Missing requirement: org.e...

I've investigated the issue and found the root cause of the osgi.ee=UNKNOWN problem.

Problem: The BREE parsing code in BundleDescriptionBuilder.getOSGiEENameVersion() was accepting any string as a valid execution environment name, even invalid values like "UNKNOWN". When a bundle had a malformed or placeholder BREE value, it would be passed through without validation, resulting in invalid osgi.ee=UNKNOWN requirements.

Solution: Added validation in createOSGiEERequirementFilter() (commit d982186) to:

  1. Reject null/empty BREE values
  2. Explicitly check for placeholder values like "UNKNOWN" and "UNSPECIFIED"
  3. Throw a clear BundleException with the format: Invalid execution environment: 'UNKNOWN'. Expected format like 'JavaSE-11' or 'JavaSE-1.8'.

This prevents bundles with invalid BREEs from being published with osgi.ee=UNKNOWN requirements, which would cause resolution failures as seen in eclipse-tycho/tycho#5446.

Testing: Added testInvalidBREEsRejected() to verify that invalid BREE values are properly rejected with clear error messages.

Copilot AI changed the title Add generic BREE support for modern Java versions (JavaSE-25+) Add generic BREE support for modern Java versions and reject invalid BREEs Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants