Is there a replacement for deprecated options -Xverify:none and -noverify that were deprecated in JDK 13?

502 Views Asked by At

The project I'm working on creates .class files that are not exactly the same as what produces JDK compiler. In particular, there's a part of the project that allows to programmatically create a .class file, and for testing, I take as input a compiler-generated class A.class and produce as output a B.class that is supposed to be almost the same. The javap outputs actually match except for indexes in the constant pool (they use the same constants but with different indexes).

When I try to launch B.class with java command without -noverify option, I have the following error:

java.lang.VerifyError: Expecting a stackmap frame at branch target 70
Exception Details:
  Location:
    ...; @10: ifeq
  Reason:
    Expected stackmap frame at this location.

If I launch with -noverify option, the java command runs successfully, but I have this warning:

Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

Also there seems to be a new option AppCDS where classes are found in a shared archive in which no verification is performed. It seems a bit out of scope for my need. What combination of options will give me the same result as noverify ?

I just have a unit test to run, for now I just disabled it for JDK 13+. Tests run on CI on various JDKs from 8 to 17.

0

There are 0 best solutions below