The CI build has recently often failed on ubuntu and macos with Java 8, due to java.lang.OutOfMemoryError: GC overhead limit exceeded.
This is due to ClassFileImporterSlowTest, which imports the full classpath in these tests:
@Test
public void imports_the_classpath_without_archives() {
JavaClasses // ...
classes = new ClassFileImporter()
.withImportOption(importJavaBaseOrRtAndJUnitJarAndFilesOnTheClasspath())
.importClasspath(); // ⚠️ imports # `JavaClass`es
and
@Test
public void importing_the_default_package_equals_importing_the_classpath() {
Set<String> classNamesOfDefaultPackageImport = new ClassFileImporter()
.withImportOption(importJavaBaseOrRtAndJUnitJarAndFilesOnTheClasspath())
.importPackages("") // ⚠️ imports # `JavaClass`es
.stream().map(JavaClass::getName).collect(toSet());
Set<String> classNamesOfClasspathImport = new ClassFileImporter()
.withImportOption(importJavaBaseOrRtAndJUnitJarAndFilesOnTheClasspath())
.importClasspath() // ⚠️ imports # `JavaClass`es
.stream().map(JavaClass::getName).collect(toSet());
and also
@Test
public void creates_JavaPackages() {
JavaClasses javaClasses = importJavaBase(); // ...
}
private JavaClasses importJavaBase() {
return new ClassFileImporter()
.withImportOption(location ->
// before Java 9 packages like java.lang were in rt.jar
location.contains("rt.jar") ||
// from Java 9 on those packages were in a JRT with name 'java.base'
(location.asURI().getScheme().equals("jrt") && location.contains("java.base"))
)
.importClasspath(); // ⚠️ imports #' `JavaClass`es
}
The number of JavaClasses for Java 8 is much higher than for later (tested) Java versions, largely due to the number of classes in com.sun or sun packages:
| Version |
# |
#' |
com.sun |
sun |
| Java 8 |
24 k |
20 k |
7 k |
4 k |
| Java 11 |
11 k |
6 k |
0.3 k |
2 k |
| Java 17 |
11 k |
6 k |
0.2 k |
2 k |
| Java 21 |
12 k |
8 k |
0.3 k |
2 k |
The test currently runs with maxHeapSize = "2G", but I've also seen it fail with 3G locally.
The CI build has recently often failed on
ubuntuandmacoswith Java 8, due tojava.lang.OutOfMemoryError: GC overhead limit exceeded.This is due to
ClassFileImporterSlowTest, which imports the full classpath in these tests:and
and also
The number of
JavaClasses for Java 8 is much higher than for later (tested) Java versions, largely due to the number of classes incom.sunorsunpackages:com.sunsunThe test currently runs with
maxHeapSize = "2G", but I've also seen it fail with3Glocally.