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
Merged
Changes from 1 commit
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
Expand Up @@ -589,12 +589,9 @@ class RelocationTest : BasePluginTest() {
"""
package my;
public class Main {
public static final String junit = "junit.framework.Test";
public static void main(String[] args) {
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.

}
""".trimIndent()
}
Expand All @@ -609,15 +606,13 @@ class RelocationTest : BasePluginTest() {
""".trimIndent(),
)

run(shadowJarTask) {
it.withDebug(true)
}
run(shadowJarTask)

val pathString = outputShadowJar.use { it.toString() }
val result = runProcess("java", "-jar", pathString)

assertThat(result).contains(
"the value is foo.junit.framework.Test",
"foo.junit.framework.Test",
)
}

Expand Down