Skip to content

Commit defa75b

Browse files
authored
Native image IncludeAllLocales (palantir#1240)
Native image IncludeAllLocales and updates reachability-metadata's resources glob to include all entries under `com/sun/tools/javac/resources/**`
1 parent eb116ce commit defa75b

4 files changed

Lines changed: 32 additions & 23 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: fix
2+
fix:
3+
description: Native image IncludeAllLocales and updates reachability-metadata's
4+
resources glob to include all entries under `com/sun/tools/javac/resources/**`
5+
links:
6+
- https://github.com/palantir/palantir-java-format/pull/1240

‎palantir-java-format-jdk-bootstrap/src/test/java/com/palantir/javaformat/bootstrap/FormatterServicesTest.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ void can_format_large_input_file(FormatterService formatterService) throws Forma
7878
});
7979
}
8080

81+
@ParameterizedTest
82+
@MethodSource("getFormatters")
83+
void no_replacements_for_invalid_input(FormatterService formatterService) throws FormatterException {
84+
String input =
85+
"""
86+
class Foo {
87+
88+
/* hello*/
89+
public void main( String aaaa ) {
90+
System.out.println("aaaaa"}; }
91+
}
92+
""";
93+
94+
assertThat(formatterService.getFormatReplacements(input, List.of(Range.open(0, input.length()))))
95+
.isEmpty();
96+
}
97+
8198
private static Stream<FormatterService> getFormatters() {
8299
return Stream.of(
83100
new BootstrappingFormatterService(

‎palantir-java-format-native/build.gradle‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ graalvmNative {
5656
configurationFileDirectories.from(file('src/main/resources/META-INF/native-image'))
5757
buildArgs.addAll(
5858
'-H:+UnlockExperimentalVMOptions',
59-
'-H:IncludeResourceBundles=com.sun.tools.javac.resources.compiler',
60-
'-H:IncludeResourceBundles=com.sun.tools.javac.resources.javac',
59+
'-H:+IncludeAllLocales',
6160
'--no-fallback',
6261
'--initialize-at-build-time=com.sun.tools.javac.file.Locations',
6362
'-H:+ReportExceptionStackTraces',
@@ -69,12 +68,6 @@ graalvmNative {
6968
}
7069
}
7170

72-
73-
// The image requires parameters to be passed to; eg. gw nativeRun -Pargs=--palantir,-i,<file>
74-
tasks.named("nativeRun", org.graalvm.buildtools.gradle.tasks.NativeRunTask) {
75-
runtimeArgs.addAll(project.hasProperty('appArgs') ? project.appArgs.split(',') : [])
76-
}
77-
7871
if (Optional.ofNullable(System.getenv("CI")).isPresent()) {
7972
externalPublishing {
8073
publication('nativeImage') {

‎palantir-java-format-native/src/main/resources/META-INF/native-image/reachability-metadata.json‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
"allDeclaredFields": true
4848
},
4949
{
50-
"type": "com.google.common.collect.SingletonImmutableList",
50+
"type": "com.google.common.collect.RegularImmutableList",
5151
"allDeclaredFields": true
5252
},
5353
{
54-
"type": "com.google.common.collect.RegularImmutableList",
54+
"type": "com.google.common.collect.SingletonImmutableList",
5555
"allDeclaredFields": true
5656
},
5757
{
@@ -164,26 +164,19 @@
164164
"glob": "META-INF/services/java.lang.System$LoggerFinder"
165165
},
166166
{
167-
"glob": "com/sun/tools/javac/resources/compiler_en.properties"
168-
},
169-
{
170-
"glob": "com/sun/tools/javac/resources/compiler_en_US.properties"
167+
"glob": "com/sun/tools/javac/resources/**"
171168
},
172169
{
173170
"module": "jdk.compiler",
174-
"glob": "com/sun/tools/javac/resources/compiler_en.properties"
175-
},
176-
{
177-
"module": "jdk.compiler",
178-
"glob": "com/sun/tools/javac/resources/compiler_en_US.properties"
171+
"glob": "com/sun/tools/javac/resources/**"
179172
}
180173
],
181174
"bundles": [
182175
{
183-
"name": "com.sun.tools.javac.resources.compiler",
184-
"locales": [
185-
"en-US"
186-
]
176+
"name": "com.sun.tools.javac.resources.compiler"
177+
},
178+
{
179+
"name": "com.sun.tools.javac.resources.javac"
187180
}
188181
],
189182
"jni": [

0 commit comments

Comments
 (0)