Skip to content

Commit

Permalink
For testing: enable new class initialization policy by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Wimmer committed May 22, 2023
1 parent b49624d commit 0310bd9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
7 changes: 6 additions & 1 deletion java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ def extra_image_build_argument(self, benchmark, args):
if mx.get_jdk().version < expectedJdkVersion:
mx.abort(benchmark + " needs at least JDK version " + str(expectedJdkVersion))

return super(BaseTikaBenchmarkSuite, self).extra_image_build_argument(benchmark, args)
return [
# Workaround for wrong class initialization configuration
'--initialize-at-build-time=org.apache.pdfbox.rendering.ImageType$1,org.apache.pdfbox.rendering.ImageType$2,org.apache.pdfbox.rendering.ImageType$3,org.apache.pdfbox.rendering.ImageType$4',
] + super(BaseTikaBenchmarkSuite, self).extra_image_build_argument(benchmark, args)


class TikaWrkBenchmarkSuite(BaseTikaBenchmarkSuite, mx_sdk_benchmark.BaseWrkBenchmarkSuite):
Expand Down Expand Up @@ -466,6 +469,8 @@ def build_assertions(self, benchmark, is_gate):
def extra_image_build_argument(self, benchmark, args):
return [
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED',
# Workaround for wrong class initialization configuration
'--initialize-at-build-time=io.netty.handler.codec.http.cookie.ServerCookieEncoder',
] + super(BaseMicronautBenchmarkSuite, self).extra_image_build_argument(benchmark, args)

def default_stages(self):
Expand Down
5 changes: 3 additions & 2 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,9 @@ def checkLine(line, marker, init_kind, msg, wrongly_initialized_lines):
with open(classes_file) as f:
for line in f:
checkLine(line, "MustBeDelayed", "RUN_TIME", "classes are initialized at run time by default", wrongly_initialized_lines)
checkLine(line, "MustBeSafeEarly", "BUILD_TIME", "class proven as side-effect free before analysis", wrongly_initialized_lines)
checkLine(line, "MustBeSafeLate", "BUILD_TIME", "class proven as side-effect free after analysis", wrongly_initialized_lines)
# temporarily disabled, without partial evaluation of class initializer we do not initialize anything at build time
# checkLine(line, "MustBeSafeEarly", "BUILD_TIME", "class proven as side-effect free before analysis", wrongly_initialized_lines)
# checkLine(line, "MustBeSafeLate", "BUILD_TIME", "class proven as side-effect free after analysis", wrongly_initialized_lines)
if len(wrongly_initialized_lines) > 0:
msg = ""
for (line, error) in wrongly_initialized_lines:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ public void afterAnalysis(AfterAnalysisAccess access) {
.collect(Collectors.toList());
if (!unspecifiedClasses.isEmpty()) {
System.err.println("The following classes have unspecified initialization policy:" + System.lineSeparator() + String.join(System.lineSeparator(), unspecifiedClasses));
UserError.abort("To fix the error either specify the initialization policy for given classes or set %s",
// Temporary not an error to allow testing of new policy
System.err.println("To fix the error either specify the initialization policy for given classes or set " +
SubstrateOptionsParser.commandArgument(ClassInitializationOptions.AssertInitializationSpecifiedForAllClasses, "-"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ private static class InitializationValueEager extends InitializationValueTransfo
public static final HostedOptionKey<Boolean> AssertInitializationSpecifiedForAllClasses = new HostedOptionKey<>(false);

@Option(help = "Use new class initialization strategy that allows all classes to be used at image build time.", type = OptionType.Expert)//
public static final HostedOptionKey<Boolean> UseNewExperimentalClassInitialization = new HostedOptionKey<>(false);
public static final HostedOptionKey<Boolean> UseNewExperimentalClassInitialization = new HostedOptionKey<>(true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,18 @@ private static void checkClasses(boolean checkSafeEarly, boolean checkSafeLate)
errors.add(checkedClass.getName() + ": Check for MustBeDelayed failed");
}
if (nameHasSafeEarly && initialized != checkSafeEarly) {
errors.add(checkedClass.getName() + ": Check for MustBeSafeEarly failed");
/*
* temporarily disabled, without partial evaluation of class initializer we do
* not initialize anything at build time
*/
// errors.add(checkedClass.getName() + ": Check for MustBeSafeEarly failed");
}
if (nameHasSafeLate && initialized != checkSafeLate) {
errors.add(checkedClass.getName() + ": Check for MustBeSafeLate failed");
/*
* temporarily disabled, without partial evaluation of class initializer we do
* not initialize anything at build time
*/
// errors.add(checkedClass.getName() + ": Check for MustBeSafeLate failed");
}
}
}
Expand Down

0 comments on commit 0310bd9

Please sign in to comment.