Skip to content

Test that string consts are relocated by default #1405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025

Conversation

Goooler
Copy link
Member

@Goooler Goooler commented Apr 17, 2025

Refs #1401.

@Goooler Goooler requested a review from Copilot April 17, 2025 10:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new functional test to verify that string constants are relocated by default when building a shadow JAR.

  • Introduces a new test function (relocateStringConstantsByDefault) that writes a simple Java class printing a string constant.
  • Configures the shadow JAR task in the build script to relocate package names and asserts the relocated string is present in the JAR's output.
Comments suppressed due to low confidence (1)

src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt:612

  • [nitpick] Consider asserting the process exit code in addition to verifying the output to fully validate that the relocated JAR executes successfully.
val result = runProcess("java", "-jar", pathString)

@Goooler Goooler enabled auto-merge (squash) April 17, 2025 10:07
Comment on lines 594 to 597
System.out.println(getValue() + junit);
System.out.println("junit.framework.Test");
}
// Use this method to force the compiler to not inline the string literal.
private static String getValue() { return "the value is "; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getValue() + junit has still been inlined, we should use a const directly.

@Goooler Goooler merged commit 785150b into main Apr 17, 2025
7 checks passed
@Goooler Goooler deleted the g/22050417/test-relocating-string branch April 17, 2025 10:14
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.

1 participant