You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2026/07/28 16:37:54 UTC
(groovy) branch GROOVY-12199 updated: GROOVY-12199: Skip string-literal relocation for java.beans on grooid
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch GROOVY-12199
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY-12199 by this push:
new 16f8e2305c GROOVY-12199: Skip string-literal relocation for java.beans on grooid
16f8e2305c is described below
commit 16f8e2305cbeffb9f75c600ef4d5e0fe7b9367a8
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Jul 29 01:37:12 2026 +0900
GROOVY-12199: Skip string-literal relocation for java.beans on grooid
Shadow rewrites bare package LDC strings that jarjar left intact, so
Java9.JAVA8_PACKAGES entries became groovyjarjaropenbeans and ModuleFinder
lookups no-oped. Keep type/descriptor remapping; only gate string constants.
---
.../apache/groovy/gradle/RepackageJarTask.groovy | 25 +++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/build-logic/src/main/groovy/org/apache/groovy/gradle/RepackageJarTask.groovy b/build-logic/src/main/groovy/org/apache/groovy/gradle/RepackageJarTask.groovy
index 2828a46b6c..292f0de6c1 100644
--- a/build-logic/src/main/groovy/org/apache/groovy/gradle/RepackageJarTask.groovy
+++ b/build-logic/src/main/groovy/org/apache/groovy/gradle/RepackageJarTask.groovy
@@ -212,13 +212,36 @@ abstract class RepackageJarTask extends ShadowJar {
// registration are honoured, without accumulating across re-runs.
relocators.empty()
for (Map.Entry<String, String> e : patterns.entrySet()) {
- relocate(toRelocationPrefix(e.key), toRelocationDestination(e.value))
+ String pattern = e.key
+ String prefix = toRelocationPrefix(pattern)
+ String destination = toRelocationDestination(e.value)
+ // Shadow matches package prefixes with startsWith, so a rule for
+ // java.beans.** also rewrites the bare string "java.beans". jarjar's
+ // ".**" wildcard required a child segment and left bare package names
+ // alone. That matters for Java9.JAVA8_PACKAGES(): those entries are
+ // real JDK package names looked up via ModuleFinder.ofSystem() — if
+ // rewritten to groovyjarjaropenbeans the lookup no-ops. Type/descriptor
+ // remapping is unaffected (skipStringConstants only gates LDC strings).
+ // See GROOVY-12199 / Bucket 4a.
+ if (shouldSkipStringConstants(prefix)) {
+ relocate(prefix, destination) { it.skipStringConstants = true }
+ } else {
+ relocate(prefix, destination)
+ }
}
super.copy()
postProcess()
}
+ /**
+ * JDK packages that may appear as bare package-name string constants (not
+ * Class.forName targets) and must stay as real platform names after shading.
+ */
+ private static boolean shouldSkipStringConstants(String packagePrefix) {
+ return packagePrefix == 'java.beans' || packagePrefix.startsWith('java.beans.')
+ }
+
private void postProcess() {
File out = archiveFile.get().asFile
// Fixed timestamp for reproducible builds (matches historical packaging).