0

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.

Sybuser
  • 735
  • 10
  • 27
  • Does this answer your question? [64-Bit Server VM Warning: Options -Xverify:none and -noverify were deprecated in JDK 13. Safe to delete -Xverify:none from Environment Variables?](https://stackoverflow.com/questions/60103574/64-bit-server-vm-warning-options-xverifynone-and-noverify-were-deprecated-in) – Turing85 Nov 20 '22 at 16:19
  • Not sure how I can use AppCDS to skip class verification? – Sybuser Nov 20 '22 at 18:22
  • 2
    You are asking the wrong question. You should ask, how you can fix your broken code generation. – Holger Nov 21 '22 at 18:45
  • @Holger your answer totally makes sense but such revamping of the project won't be accepted by maintainer for now, we must raise the code coverage first, which is too low. – Sybuser Nov 21 '22 at 21:14
  • The closest replacement for `-noverify` is `-XX:+CrashJVMAtRandomTimes`, for example, see [this](https://stackoverflow.com/questions/40321205/jvm-crash-problematic-frame-canonicalizerdo-if) and [this](https://stackoverflow.com/questions/58855063/jvm-exception-access-violation-crash-in-spring-boot-application). – apangin Nov 22 '22 at 06:07
  • 1
    @Sybuser that’s a strange point of view. A code generator whose output doesn’t pass the verifier, is *broken* and if “maintainer” means “maintainer of that software”, accepting a request to fix the software is not a matter of choice at all. – Holger Nov 22 '22 at 08:27
  • @Holger better code coverage will help fix this safely limiting side effects, such fix will eventually be accepted. – Sybuser Nov 22 '22 at 09:06
  • 1
    The bug is there and is reproducible. I don’t know what you mean with “better code coverage” in this context. What you are asking for, is a way to hide the problem. It’s not clear, how this should help fixing the bug in any way. You should do the opposite, remove the `-noverify` option from the testcases, to demonstrate that the problem occurs in all versions. And again, you used the word “accepted” as if it was a matter of choice whether serious bugs like this have to be fixed. This is not a matter of opinion. You don’t have to beg for acceptance. – Holger Nov 23 '22 at 12:58
  • There's no bug here. It's just that the stack map frames are not supported yet in bcel. And I may or may not do something about it. – Sybuser Nov 23 '22 at 18:16
  • "BCEL ought to automatically build and maintain the StackMapTable in a manner similar to the LineNumberTable and the LocalVariableTable. However, for historical reasons, it does not." http://plumelib.org/bcel-util/api/org/plumelib/bcelutil/StackMapUtils.html https://github.com/plume-lib/bcel-util/blob/master/src/main/java/org/plumelib/bcelutil/StackMapUtils.java – Sybuser Nov 23 '22 at 19:43

0 Answers0