Does "-cv" option to jasm tool override the class file version in jasm file?
Leonid Kuskov
leonid.kuskov at oracle.com
Thu Dec 11 21:49:25 UTC 2025
In typical usage, a .jasm file explicitly specifies the class-file version in its header, for example:
test.jasm
public super class test version 55:0 {}
If the version isn't specified in the file, jasm defaults to 45.3.
When a version is present in the .jasm file, the -cv option doesn’t override it. For example, given a header such as:
public super class test version 55:0 {}
and the command:
jasm -cv 66.0 -w . test.jasm
the generated class file will still use version 55.0, because the version defined in the source takes precedence.
If your intention is to force the class-file version - regardless of whether the .jasm file declares one, then you must use:
jasm -fixcv 66.0 -w . test.jasm
The -fixcv option overrides the version unconditionally, while -cv supplies only a fallback value that is used only if the source file does not specify a version.
The options (-fixcv, -cv) were added to support batch updates of large sets of .jasm files. In general, it is preferable to specify the correct class-file version directly in the .jasm source.
Leonid
BTW: The latest asmtools release is 9.1, which is preferable to version 8.1 for new or updated workflows.
Confidential- Oracle Internal
From: asmtools-dev <asmtools-dev-retn at openjdk.org> on behalf of Jaikiran Pai <jaikiran.pai at oracle.com>
Date: Wednesday, December 10, 2025 at 9:06 PM
To: asmtools-dev at openjdk.org <asmtools-dev at openjdk.org>
Subject: Does "-cv" option to jasm tool override the class file version in jasm file?
When running some jtreg tests that use ".jasm" files, I see this warning
being emitted by asmtools:
mexit02a.jasm (24:19) Warning: Class file version not specified in file
or by -cv parameter. Defaulting to version "45:3"
jtreg uses 8.1 version of asmtools and launches
org.openjdk.asmtools.jasm.Main to compile these jasm files. Right now it
doesn't pass any class file version parameter when launching that tool.
To prevent the above warning, I was considering passing "-cv" option to
specify a class file version that would be used if the ".jasm" file
being compiled didn't explicitly have one. However, I then looked at the
code in org.openjdk.asmtools.jasm.Main and that has this comment for
this option parsing
https://github.com/openjdk/asmtools/blob/8.1/src/org/openjdk/asmtools/jasm/Main.java#L216
:
// overrides cf version even if it's defined in the source file.
case "-fixcv", "-cv" -> {
...
Is that comment accurate? Would passing "-cv" option to the tool
override the class file version that's present in any .jasm file? I
would like it to be used as a fallback default version if there isn't
one set in the jasm files.
-Jaikiran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/asmtools-dev/attachments/20251211/b8ebec4d/attachment.htm>
More information about the asmtools-dev
mailing list