Skip to content

Commit

Permalink
Support building and running on JDK 22 (#1419)
Browse files Browse the repository at this point in the history
We don't immediately crash on JDK 22 bytecodes, but new bytecode
features have not been tested.

We modify the `TestList` test input to avoid a blowup when running
`SlicerTest.testList`.
openjdk/jdk@b62e774
introduced calls to `String.format` from `Integer.parseInt`, which
dramatically increased the number of reachable methods for the previous
version of this test, which in turn led to very slow performance with
the slicer. Changing the test to use a `List<String>` and string
constants removes this blowup. (Whole-program analysis is fun!)

Fixes #1414
  • Loading branch information
msridhar authored Jul 20, 2024
1 parent 96cb898 commit 594587c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
java: 17
- os: ubuntu-latest
java: 21
- os: ubuntu-latest
java: 22
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ public void testList()
.filter(s -> s instanceof NormalStatement && s.getNode().equals(main))
.collect(Collectors.toList());
normalsInMain.stream().forEach(System.err::println);
assertEquals(7, normalsInMain.size());
assertEquals(5, normalsInMain.size());
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions core/src/testSubjects/java/slice/TestList.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class TestList {
static void doNothing(Object o) {}

public static void main(String[] args) {
List<Integer> list = new ArrayList<>();
List<String> list = new ArrayList<>();

list.add(2);
list.add(3);
list.add("hi");
list.add("bye");

doNothing(list.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ private void parse() throws InvalidClassFileException {
if (magic != MAGIC) {
throw new InvalidClassFileException(offset, "bad magic number: " + magic);
}
// Support class files up through JDK 21 (version 65)
if (majorVersion < 45 || majorVersion > 65) {
// Support class files up through JDK 22 (version 66)
if (majorVersion < 45 || majorVersion > 66) {
throw new InvalidClassFileException(
offset, "unknown class file version: " + majorVersion + '.' + minorVersion);
}
Expand Down

0 comments on commit 594587c

Please sign in to comment.