pax_global_header 0000666 0000000 0000000 00000000064 15143236361 0014516 g ustar 00root root 0000000 0000000 52 comment=4bd7c96db2e5e99319470fa5d55f9cbe1a1898d8
jtreg8-8.2.1+1+ds1/ 0000775 0000000 0000000 00000000000 15143236361 0013550 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/.gitignore 0000664 0000000 0000000 00000000053 15143236361 0015536 0 ustar 00root root 0000000 0000000 /build/
/.idea/
/webrev
.DS_Store
.src-rev
jtreg8-8.2.1+1+ds1/.hgignore 0000664 0000000 0000000 00000000113 15143236361 0015346 0 ustar 00root root 0000000 0000000 ^(build|dist)/
nbproject/private/
plugins/idea/.idea/
plugins/idea/build/
jtreg8-8.2.1+1+ds1/.hgtags 0000664 0000000 0000000 00000003457 15143236361 0015037 0 ustar 00root root 0000000 0000000 9f51ef22f00a3d5b681472cacf3ce15868073103 jtreg4.1-b01
2cf779985e18ba2f79aaec88f543be9efecf352f jtreg4.1-b02
bd7a3ed1210fa61f92f066c65d5e589e2aa26813 jtreg4.1-b03
cbc1f04a52ea2488e8dc7715fc59a5a122be9851 jtreg4.1-b04
46b8c02be3b356c7f953dbfa18246b357b5e7101 jtreg4.1-b05
d47a6e238c3e0f6d8ca1a6640c182be14c45eab2 jtreg-4.1-b06
d47a6e238c3e0f6d8ca1a6640c182be14c45eab2 jtreg4.1-b06
8ab579624a503e1df21841070ae5f869c301de8f jtreg4.1-b07
d47a6e238c3e0f6d8ca1a6640c182be14c45eab2 jtreg-4.1-b06
0000000000000000000000000000000000000000 jtreg-4.1-b06
e08a5e0b79ba57743222bbea19c0bdb142968769 jtreg4.1-b08
c54815dea64cf7b011f8473c18d54a86b9a9d5af jtreg4.1-b09
8c3179c3ebdab7df35b8e9907bd8ad8bc5a9f9f8 jtreg4.1-b10
04f40c388713f11c1cfb2094556d4b024b9ab939 jtreg4.1-b11
79705dae19e74b0693cda9ece8eaf0984159ab97 jtreg4.1-b12
5e994d1f9840ba39b82977a56e02c4f702a1dcbd jtreg4.1-b13
1159c9f96a4470dec79e6fa71b4f1a4895c4b20f jtreg4.2-b01
dbccea90c34dacf7e0824d5e3d3e9e1e930a103a jtreg4.2-b02
45590e2d6af12da44cc160764a9b552516be8440 jtreg4.2-b03
585f794e105997ab44109d70dbaa1c072b03afcc jtreg4.2-b04
4b0cd55e7741825de6ea79e9d4338d2972460678 jtreg4.2-b05
2d96b4cf02660b1580542379d77492f68d3ca73b jtreg4.2-b06
26d8a4a47674c4ca304b9e290dccca1dd1c7224f jtreg4.2-b07
cce0ac75e87864ed365a420fb836a4430421ab0f jtreg4.2-b08
684f12eef4a8c2f42afe2abe3d79eead72efcc5f jtreg4.2-b09
746c6d1328721541d3b16154c25a0179fbf53f7c jtreg4.2-b10
a13ec77e7adcc4c9ed434e664abc350abaacc045 jtreg4.2-b11
652902f7fb0ed0b4f307d61a799caf50a6e609be jtreg4.2-b12
7a38f21e077821a5015792e85b3793c90c81b866 jtreg4.2-b13
ec37d2900cd42987270f98423a60eb6297bdc37b jtreg4.2-b14
d5a9216fad5ca01002e18526be2c31cafb43e178 jtreg4.2-b15
deee95d5d8ff6406b77c0d5b9297736eb7c98c6d jtreg4.2-b16
03c4dff80b0f55865c6e5fe0aa8ea94d0ca1a2ac jtreg5.0-b01
95aa601b8100c6c56a14d35cfe493372214b1d94 jtreg5.1-b01
jtreg8-8.2.1+1+ds1/.jcheck/ 0000775 0000000 0000000 00000000000 15143236361 0015055 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/.jcheck/conf 0000664 0000000 0000000 00000001067 15143236361 0015731 0 ustar 00root root 0000000 0000000 [general]
project=code-tools
comments=lax
jbs=CODETOOLS
[checks]
error=author,committer,reviewers,merge,issues,executable,symlink,message,whitespace
[repository]
tags=jtreg(?:4\.1-b[0-9]{2}|5\.[01]-b[0-9]{2}|6|-[6789](?:\.[0-9]+)*\+[0-9]+)
branches=
[census]
version=0
domain=openjdk.org
[checks "whitespace"]
files=.*\.java|.*\.m|.*\.mm|.*\.gmk|.*\.m4|.*\.ac|Makefile
ignore-tabs=.*\.gmk|Makefile
[checks "merge"]
message=Merge
[checks "reviewers"]
reviewers=1
ignore=duke
[checks "committer"]
role=committer
[checks "issues"]
pattern=^(79[0-9]{5}): (\S.*)$
jtreg8-8.2.1+1+ds1/CHANGELOG.md 0000664 0000000 0000000 00000036453 15143236361 0015374 0 ustar 00root root 0000000 0000000 ## [Unreleased](https://git.openjdk.org/jtreg/compare/jtreg-8.2.1+1...master)
_nothing noteworthy, yet_
## [8.2.1](https://git.openjdk.org/jtreg/compare/jtreg-8.2+1...jtreg-8.2.1+1)
* Fixup release without any changes compared to [8.2](#82)
## [8.2](https://git.openjdk.org/jtreg/compare/jtreg-8.1+1...jtreg-8.2+1)
* Improving handling of JASM files:
* Use 45.3 (representing Java 1.1) as the default class file version, if the JASM file(s) don't have any specific class file version in them.
[CODETOOLS-7904133](https://bugs.openjdk.org/browse/CODETOOLS-7904133)
* Prevent JASM-related log messages on stdout [CODETOOLS-7904121](https://bugs.openjdk.org/browse/CODETOOLS-7904121)
* Update bundled dependencies:
* AsmTools 9.1 [CODETOOLS-7904130](https://bugs.openjdk.org/browse/CODETOOLS-7904130)
* JUnit 5.14.2 [CODETOOLS-7904129](https://bugs.openjdk.org/browse/CODETOOLS-7904129)
## [8.1](https://git.openjdk.org/jtreg/compare/jtreg-8+2...jtreg-8.1+1)
* Improve time(out)-related logging:
* [CODETOOLS-7903816](https://bugs.openjdk.org/browse/CODETOOLS-7903816)
* [CODETOOLS-7903894](https://bugs.openjdk.org/browse/CODETOOLS-7903894)
* [CODETOOLS-7904067](https://bugs.openjdk.org/browse/CODETOOLS-7904067)
* [CODETOOLS-7904088](https://bugs.openjdk.org/browse/CODETOOLS-7904088)
* `XAUTHORITY` environment variable is now preserved when launching tests on Unix-like platforms.
[CODETOOLS-7904016](https://bugs.openjdk.org/browse/CODETOOLS-7904016)
* Update bundled dependencies:
* JUnit 5.13.4 [CODETOOLS-7904070](https://bugs.openjdk.org/browse/CODETOOLS-7904070)
## [8](https://git.openjdk.org/jtreg/compare/jtreg-7.5.2+1...jtreg-8+2)
* Require JDK 17 to build `jtreg` tool. [CODETOOLS-7904000](https://bugs.openjdk.org/browse/CODETOOLS-7904000)
* Update bundled dependencies:
* AsmTools 8.1 [CODETOOLS-7903081](https://bugs.openjdk.org/browse/CODETOOLS-7903081)
* JUnit 5.13.3 [CODETOOLS-7904055](https://bugs.openjdk.org/browse/CODETOOLS-7904055)
* Fix `--verify-exclude` to abort test runs when discovering failures [CODETOOLS-7904015](https://bugs.openjdk.org/browse/CODETOOLS-7904015)
* Fix to use default charset when reading group files [CODETOOLS-7904021](https://bugs.openjdk.org/browse/CODETOOLS-7904021)
## [7.5.2](https://git.openjdk.org/jtreg/compare/jtreg-7.5.1+1...jtreg-7.5.2+1)
* Support `${test.main.class}` for Java source files in smart arguments [CODETOOLS-7903981](https://bugs.openjdk.org/browse/CODETOOLS-7903981)
* Make default timeout seconds configurable [CODETOOLS-7903961](https://bugs.openjdk.org/browse/CODETOOLS-7903961)
* Restore propagation of preview flag into library code [CODETOOLS-7903971](https://bugs.openjdk.org/browse/CODETOOLS-7903971)
* Add support for `.jasm` and `.jcod` file in patched modules [CODETOOLS-7903955](https://bugs.openjdk.org/browse/CODETOOLS-7903955)
* Use scratch directory for JUnit's `@TempDir` annotation by default [CODETOOLS-7903953](https://bugs.openjdk.org/browse/CODETOOLS-7903953)
## [7.5.1](https://git.openjdk.org/jtreg/compare/jtreg-7.5+1...jtreg-7.5.1+1)
* Support running individual parameterized tests and @Nested test classes [CODETOOLS-7903930](https://bugs.openjdk.org/browse/CODETOOLS-7903930)
* Remove problematic implementation for `LIBRARY.properties` support [CODETOOLS-7903940](https://bugs.openjdk.org/browse/CODETOOLS-7903940)
* Add `test.thread.factory` property to filter tests based on test thread factory value [CODETOOLS-7903931](https://bugs.openjdk.org/browse/CODETOOLS-7903931)
* Fix and improve `--verify-exclude` feature
[CODETOOLS-7903883](https://bugs.openjdk.org/browse/CODETOOLS-7903883)
[CODETOOLS-7903935](https://bugs.openjdk.org/browse/CODETOOLS-7903935)
## [7.5](https://git.openjdk.org/jtreg/compare/jtreg-7.4+1...jtreg-7.5+1)
* Restore `jtdiff` tool [CODETOOLS-7903760](https://bugs.openjdk.org/browse/CODETOOLS-7903760)
* Add support for `LIBRARY.properties` file in the directory specified in the `@library` tag [CODETOOLS-7903775](https://bugs.openjdk.org/browse/CODETOOLS-7903775)
* The verbose option given at the command-line is now propagated to test agents, including the JUnit test runner.
[CODETOOLS-7903443](https://bugs.openjdk.org/browse/CODETOOLS-7903443)
[CODETOOLS-7903745](https://bugs.openjdk.org/browse/CODETOOLS-7903745)
* Report test duration information in JUnit and TestNG-based tests
[CODETOOLS-7903752](https://bugs.openjdk.org/browse/CODETOOLS-7903752)
[CODETOOLS-7903753](https://bugs.openjdk.org/browse/CODETOOLS-7903753)
* Improve message when test times out in Agent VM mode [CODETOOLS-7902346](https://bugs.openjdk.org/browse/CODETOOLS-7902346)
* Log time spent waiting to acquire exclusive access lock [CODETOOLS-7903188](https://bugs.openjdk.org/browse/CODETOOLS-7903188)
* Speed-up error reporting on hosts with slow hostname lookups [CODETOOLS-7903746](https://bugs.openjdk.org/browse/CODETOOLS-7903746)
* Updated jtreg to bundle JUnit 5.11.0 [CODETOOLS-7903821](https://bugs.openjdk.org/browse/CODETOOLS-7903821)
## [7.4](https://git.openjdk.org/jtreg/compare/jtreg-7.3.1+1...jtreg-7.4+1)
* Remove support for `jtdiff` [CODETOOLS-7903622](https://bugs.openjdk.org/browse/CODETOOLS-7903622)
* jtreg now verifies ProblemList files [CODETOOLS-7903659](https://bugs.openjdk.org/browse/CODETOOLS-7903659)
* jtreg no longer ignores VM exit code when test process reports status with "STATUS: " line [CODETOOLS-7903621](https://bugs.openjdk.org/browse/CODETOOLS-7903621)
* Use SOURCE_BUILD_EPOCH to support reproducible builds
[CODETOOLS-7903539](https://bugs.openjdk.org/browse/CODETOOLS-7903539)
* Updated jtreg to bundle JUnit 5.10.2 [CODETOOLS-7903578](https://bugs.openjdk.org/browse/CODETOOLS-7903578)
* jtreg, when communicating with the AgentServer in agentvm mode, will now bind to loopback address.
[CODETOOLS-7903686](https://bugs.openjdk.org/browse/CODETOOLS-7903686)
* jtreg, in certain cases, would incorrectly report a test as PASSED when the test process would exit with a non-zero exit code.
[CODETOOLS-7903621](https://bugs.openjdk.org/browse/CODETOOLS-7903621)
## [7.3.1](https://git.openjdk.org/jtreg/compare/jtreg-7.3+1...jtreg-7.3.1+1)
* Fixed setting default environment variables on Windows
* [CODETOOLS-7903515](https://bugs.openjdk.org/browse/CODETOOLS-7903515)
## [7.3](https://git.openjdk.org/jtreg/compare/jtreg-7.2+1...jtreg-7.3+1)
* Updated set of default environment variables set for tests on Unix-like platforms.
* Includes `DBUS_SESSION_BUS_ADDRESS`, `WAYLAND_DISPLAY`, and `XDG-*`
[CODETOOLS-7903400](https://bugs.openjdk.org/browse/CODETOOLS-7903400)
* Updated external dependencies.
* Guice to 5.1.0 [CODETOOLS-7903468](https://bugs.openjdk.org/browse/CODETOOLS-7903468)
* JCommander to 1.82 [CODETOOLS-7903469](https://bugs.openjdk.org/browse/CODETOOLS-7903469)
* Fixed output-related issues.
* AgentServer log() does not flush [CODETOOLS-7903470](https://bugs.openjdk.org/browse/CODETOOLS-7903470)
* System.out and System.err messages are missing in jtr file when a test times out in agentvm mode [CODETOOLS-7903441](https://bugs.openjdk.org/browse/CODETOOLS-7903441)
* Timeout refired %s times message confusing [CODETOOLS-7902485](https://bugs.openjdk.org/browse/CODETOOLS-7902485)
* Fixed race-condition when running tests with a multi-module setup
* [CODETOOLS-7903507](https://bugs.openjdk.org/browse/CODETOOLS-7903507)
## [7.2](https://git.openjdk.org/jtreg/compare/jtreg-7.1.1+1...jtreg-7.2+1)
* Improved support for JUnit Jupiter.
* Update jtreg to bundle JUnit 5.9.2 [CODETOOLS-7903406](https://bugs.openjdk.org/browse/CODETOOLS-7903406)
* Improve reporting for errors in JUnit's lifecycle methods [CODETOOLS-7903430](https://bugs.openjdk.org/browse/CODETOOLS-7903430)
* Improved support for TestNG.
* Support `test.query` for TestNG tests [CODETOOLS-7903414](https://bugs.openjdk.org/browse/CODETOOLS-7903414)
* Generate all debugging info when compiling `jtreg` [CODETOOLS-7903393](https://bugs.openjdk.org/browse/CODETOOLS-7903393)
* RISC-V Port has been integrated into JDK mainline
* Set `simpleArch` to `riscv64` when `os.arch` is `riscv64` [CODETOOLS-7903138](https://bugs.openjdk.org/browse/CODETOOLS-7903138)
* Fix incorrect format for version in error message [CODETOOLS-7903398](https://bugs.openjdk.org/browse/CODETOOLS-7903398)
* Add options -testThreadFactory and -testThreadFactoryPath to allow
the use of a custom thread factory, to be used to create the thread to run a test.
* [CODETOOLS-7903373](https://bugs.openjdk.org/browse/CODETOOLS-79033734)
## [7.1.1](https://git.openjdk.org/jtreg/compare/jtreg-7.1+1...jtreg-7.1.1+1)
* Summary reporter getter is now thread-safe.
* [CODETOOLS-7903390](https://bugs.openjdk.org/browse/CODETOOLS-7903390)
## [7.1](https://git.openjdk.org/jtreg/compare/jtreg-7+1...jtreg-7.1+1)
* Improved support for JUnit Jupiter.
* Avoid using TestNG mixed mode.
[CODETOOLS-7903264](https://bugs.openjdk.org/browse/CODETOOLS-7903264)
* Support JUnit tests in a system module.
[CODETOOLS-7903260](https://bugs.openjdk.org/browse/CODETOOLS-7903260)
* Support executing a single method.
[CODETOOLS-7903267](https://bugs.openjdk.org/browse/CODETOOLS-7903267)
* Improve per-class reporting of JUnit tests, in `.jtr` file.
[CODETOOLS-7903324](https://bugs.openjdk.org/browse/CODETOOLS-7903324)
* Support a group of "all tests", represented by `.`.
* [CODETOOLS-7903331](https://bugs.openjdk.org/browse/CODETOOLS-7903331)
* Improve performance when writing reports; new reporting option `-report:files`.
* [CODETOOLS-7903323](https://bugs.openjdk.org/browse/CODETOOLS-7903323)
* Updates for building jtreg with recent JDKs.
* [CODETOOLS-7903346](https://bugs.openjdk.org/browse/CODETOOLS-7903346)
* Improve OS detection on Mac.
* Use `sw_vers`. [CODETOOLS-7903294](https://bugs.openjdk.org/browse/CODETOOLS-7903294)
* Check process exit code. [CODETOOLS-7903325](https://bugs.openjdk.org/browse/CODETOOLS-7903325)
* Trace reasons to recompile extra property definition files.
* [CODETOOLS-7903329](https://bugs.openjdk.org/browse/CODETOOLS-7903329)
* FAQ updates.
* Time taken to run tests. [CODETOOLS-7903261](https://bugs.openjdk.org/browse/CODETOOLS-7903261)
* Accessing TestNG and JUnit libraries. [CODETOOLS-7903244](https://bugs.openjdk.org/browse/CODETOOLS-7903244)
## [7](https://git.openjdk.org/jtreg/compare/jtreg-6.2+1...jtreg-7+1)
* Improved support for JUnit Jupiter.
* Use JUnit Platform Launcher. [CODETOOLS-7903047](https://bugs.openjdk.org/browse/CODETOOLS-7903047)
* Use JUnit uber-jar. [CODETOOLS-7903055](https://bugs.openjdk.org/browse/CODETOOLS-7903055)
* Support MSYS2 for building jtreg on Windows.
* [CODETOOLS-7903206](https://bugs.openjdk.org/browse/CODETOOLS-7903206)
* `os.simpleArch` is `x64` for `linux-loongarch64`/`mips64`/`mips64el` in `@require` context.
* [CODETOOLS-7903120](https://bugs.openjdk.org/browse/CODETOOLS-7903120)
* Log start time for every action.
* [CODETOOLS-7903183](https://bugs.openjdk.org/browse/CODETOOLS-7903183)
* Update OS version check.
* [CODETOOLS-7903184](https://bugs.openjdk.org/browse/CODETOOLS-7903184)
* Support invocation via ToolProvider.
* [CODETOOLS-7903097](https://bugs.openjdk.org/browse/CODETOOLS-7903097)
* Report `os.*` system properties in `.jtr` file.
* [CODETOOLS-7903044](https://bugs.openjdk.org/browse/CODETOOLS-7903044)
## [6.2](https://git.openjdk.org/jtreg/compare/jtreg-6.1+1...jtreg-6.2+1)
* Provide system property or option to override timeout.
* [CODETOOLS-7903083](https://bugs.openjdk.org/browse/CODETOOLS-7903083)
* Updates for building jtreg with recent JDKs.
* [CODETOOLS-7903073](https://bugs.openjdk.org/browse/CODETOOLS-7903073)
* Add an FAQ entry for `javatest.maxOutputSize`.
* [CODETOOLS-7903050](https://bugs.openjdk.org/browse/CODETOOLS-7903050)
* Allow subtest ids with dashes and underscores.
* [CODETOOLS-7903037](https://bugs.openjdk.org/browse/CODETOOLS-7903037)
* jtreg should print stdout if JVM gathering properties fails.
* [CODETOOLS-7903030](https://bugs.openjdk.org/browse/CODETOOLS-7903030)
## [6.1](https://git.openjdk.org/jtreg/compare/jtreg-6+1...jtreg-6.1+1)
* Elapsed time of `MainAction` is including serialization wait time
* [CODETOOLS-7902942](https://bugs.openjdk.org/browse/CODETOOLS-7902942)
* Support building jtreg with recent JDKs.
* [CODETOOLS-7902966](https://bugs.openjdk.org/browse/CODETOOLS-7902966)
* [CODETOOLS-7902991](https://bugs.openjdk.org/browse/CODETOOLS-7902991)
* Update/improve jcheck settings for jtreg repo.
* [CODETOOLS-7902995](https://bugs.openjdk.org/browse/CODETOOLS-7902995)
* Introduce support for `HEADLESS` to disable tests that require a display.
* jtreg should not set a security manager for JDK 18.
* [CODETOOLS-7902990](https://bugs.openjdk.org/browse/CODETOOLS-7902990)
## [6](https://git.openjdk.org/jtreg/compare/jtreg5.1-b01...jtreg-6+1)
* Add support for `Automatic-Module-Name` in jar files.
* Update versions of jtreg dependencies.
* [CODETOOLS-7902791](https://bugs.openjdk.org/browse/CODETOOLS-7902791)
* User modules can be used only in othervm.
* [CODETOOLS-7902707](https://bugs.openjdk.org/browse/CODETOOLS-7902707)
* Improve diagnostic output when failing to get version for JDK under test.
* [CODETOOLS-7902748](https://bugs.openjdk.org/browse/CODETOOLS-7902748)
* Initial support for new-style version numbers for jtreg.
* Improve support for `@enablePreview`.
* [CODETOOLS-7902754](https://bugs.openjdk.org/browse/CODETOOLS-7902754)
* Move details of environment variables to new appendix.
* Add FAQ reference to `doc/testing.md`.
* Add support for explicit `-retain:lastRun`.
## [5.1](https://git.openjdk.org/jtreg/compare/jtreg5.0-b01...jtreg5.1-b01)
* Update AsmTools to 7.0 b08; update JT Harness to 6.0-b11.
* Add `test.name` to properties given to test.
* [CODETOOLS-7902671](https://bugs.openjdk.org/browse/CODETOOLS-7902671)
* Pass `test.*` to `requires.extraPropDefns` classes.
* [CODETOOLS-7902336](https://bugs.openjdk.org/browse/CODETOOLS-7902336)
* Add mean, standard deviation to agent stats.
* Report jtreg version info to work directory.
* Report agent pool statistics.
* Improve version details for JT Harness and AsmTools.
* Log Agent Pool activity to `agent.trace` file.
* Catch output written to agent stdout (fd1) and stderr (fd2).
* [CODETOOLS-7902657](https://bugs.openjdk.org/browse/CODETOOLS-7902657)
* Log agent activity to files in the work directory.
* [CODETOOLS-7902656](https://bugs.openjdk.org/browse/CODETOOLS-7902656)
* Propagate client-side "id" to agent server.
* [CODETOOLS-7902655](https://bugs.openjdk.org/browse/CODETOOLS-7902655)
* Support `@enablePreview`.
* [CODETOOLS-7902654](https://bugs.openjdk.org/browse/CODETOOLS-7902654)
* Use https://git.openjdk.org for CODE_TOOLS_URL.
* [CODETOOLS-7902637](https://bugs.openjdk.org/browse/CODETOOLS-7902637)
* Ignore specified lines in `@compile/fail/ref=`.
* [CODETOOLS-7902633](https://bugs.openjdk.org/browse/CODETOOLS-7902633)
* Validate test group names.
* [CODETOOLS-7902606](https://bugs.openjdk.org/browse/CODETOOLS-7902606)
## [5](https://git.openjdk.org/jtreg/compare/jtreg4.2-b16...jtreg5.0-b01)
* Improve Cygwin detection by relaxing constraints on expected installation directory.
* Incorrect handling of paths in smart action args for Windows.
* [CODETOOLS-7902571](https://bugs.openjdk.org/browse/CODETOOLS-7902571)
* Introduce `test.file`.
* [CODETOOLS-7902545](https://bugs.openjdk.org/browse/CODETOOLS-7902545)
jtreg8-8.2.1+1+ds1/CONTRIBUTING.md 0000664 0000000 0000000 00000000307 15143236361 0016001 0 ustar 00root root 0000000 0000000 # Contributing to JTReg
JTReg is part of the OpenJDK [CodeTools] Project.
Please see for how to contribute.
[CodeTools]: https://openjdk.org/projects/code-tools
jtreg8-8.2.1+1+ds1/CONTRIBUTORS 0000664 0000000 0000000 00000001072 15143236361 0015430 0 ustar 00root root 0000000 0000000 The following people have contributed to the development of jtreg.
Original Author:
Iris Clark
Tag Specification:
Mark Reinhold
Currently Maintained As Part Of:
OpenJDK CodeTools Project
Other Early Contributors:
Brian Kurotsuchi
Dawn Phillips
Jessica Mauvais
John Rose
Maurizio Cimadamore
Kumar Srinivasan
Since open-sourcing the code in 2006, and the use of first Mercurial and
subsequently Git, the Contributors are tracked in the SCM metadata.
For all recent contributors and contributions, see `git shortlog` or `git log`.
jtreg8-8.2.1+1+ds1/COPYRIGHT 0000664 0000000 0000000 00000001742 15143236361 0015047 0 ustar 00root root 0000000 0000000 Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
or visit www.oracle.com if you need additional information or have any
questions.
jtreg8-8.2.1+1+ds1/LICENSE 0000664 0000000 0000000 00000045512 15143236361 0014564 0 ustar 00root root 0000000 0000000 The GNU General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software is
covered by the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom to
distribute copies of free software (and charge for this service if you wish),
that you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs; and that you know you
can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny
you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for
a fee, you must give the recipients all the rights that you have. You must
make sure that they, too, receive or can get the source code. And you must
show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients to
know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will
individually obtain patent licenses, in effect making the program proprietary.
To prevent this, we have made it clear that any patent must be licensed for
everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms of
this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or
translated into another language. (Hereinafter, translation is included
without limitation in the term "modification".) Each licensee is addressed as
"you".
Activities other than copying, distribution and modification are not covered by
this License; they are outside its scope. The act of running the Program is
not restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made by
running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as
you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the
Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may
at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus
forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all of
these conditions:
a) You must cause the modified files to carry prominent notices stating
that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of
this License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the
most ordinary way, to print or display an announcement including an
appropriate copyright notice and a notice that there is no warranty (or
else, saying that you provide a warranty) and that users may redistribute
the program under these conditions, and telling the user how to view a copy
of this License. (Exception: if the Program itself is interactive but does
not normally print such an announcement, your work based on the Program is
not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License, and
its terms, do not apply to those sections when you distribute them as separate
works. But when you distribute the same sections as part of a whole which is a
work based on the Program, the distribution of the whole must be on the terms
of this License, whose permissions for other licensees extend to the entire
whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise the
right to control the distribution of derivative or collective works based on
the Program.
In addition, mere aggregation of another work not based on the Program with the
Program (or with a work based on the Program) on a volume of a storage or
distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1 and
2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above
on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to
give any third party, for a charge no more than your cost of physically
performing source distribution, a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of Sections 1
and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to
distribute corresponding source code. (This alternative is allowed only
for noncommercial distribution and only if you received the program in
object code or executable form with such an offer, in accord with
Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code
distributed need not include anything that is normally distributed (in either
source or binary form) with the major components (compiler, kernel, and so on)
of the operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the source
code from the same place counts as distribution of the source code, even though
third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies, or
rights, from you under this License will not have their licenses terminated so
long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it.
However, nothing else grants you permission to modify or distribute the Program
or its derivative works. These actions are prohibited by law if you do not
accept this License. Therefore, by modifying or distributing the Program (or
any work based on the Program), you indicate your acceptance of this License to
do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor to
copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of the
rights granted herein. You are not responsible for enforcing compliance by
third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution
of the Program by all those who receive copies directly or indirectly through
you, then the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose that
choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original
copyright holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In
such case, this License incorporates the limitation as if written in the body
of this License.
9. The Free Software Foundation may publish revised and/or new versions of the
General Public License from time to time. Such new versions will be similar in
spirit to the present version, but may differ in detail to address new problems
or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any later
version", you have the option of following the terms and conditions either of
that version or of any later version published by the Free Software Foundation.
If the Program does not specify a version number of this License, you may
choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status of
all derivatives of our free software and of promoting the sharing and reuse of
software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
One line to give the program's name and a brief idea of what it does.
Copyright (C)
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it
starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free
software, and you are welcome to redistribute it under certain conditions;
type 'show c' for details.
The hypothetical commands 'show w' and 'show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than 'show w' and 'show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
'Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General Public
License instead of this License.
"CLASSPATH" EXCEPTION TO THE GPL
Certain source files distributed by Oracle America and/or its affiliates are
subject to the following clarification and special exception to the GPL, but
only where Oracle has expressly included in the particular source file's header
the words "Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the LICENSE file that accompanied this code."
Linking this library statically or dynamically with other modules is making
a combined work based on this library. Thus, the terms and conditions of
the GNU General Public License cover the whole combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,
and to copy and distribute the resulting executable under terms of your
choice, provided that you also meet, for each linked independent module,
the terms and conditions of the license of that module. An independent
module is a module which is not derived from or based on this library. If
you modify this library, you may extend this exception to your version of
the library, but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version.
jtreg8-8.2.1+1+ds1/README.md 0000664 0000000 0000000 00000001401 15143236361 0015023 0 ustar 00root root 0000000 0000000 # The Regression Test Harness for the OpenJDK platform: `jtreg`
* For details on writing tests for `jtreg`, see
[The JDK Test Framework: Tag Language Specification][tagspec].
* For details on building `jtreg`, see
[doc/building.md](doc/building.md).
* For additional details about `jtreg`, see
[The `jtreg` FAQ][faq].
* For details on running JDK tests using the JDK _make test_ framework, see
[Using "make test" (the run-test framework)][make-test].
* For details on running jtreg tests using the IntelliJ IDE, see
[plugins/idea/README.md](plugins/idea/README.md)
[faq]: https://openjdk.org/jtreg/faq.html
[tagspec]: https://openjdk.org/jtreg/tag-spec.html
[make-test]: https://github.com/openjdk/jdk/blob/master/doc/testing.md
## Using IntelliJ IDEA
jtreg8-8.2.1+1+ds1/apiguardian/ 0000775 0000000 0000000 00000000000 15143236361 0016034 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/.github/ 0000775 0000000 0000000 00000000000 15143236361 0017374 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/.github/workflows/ 0000775 0000000 0000000 00000000000 15143236361 0021431 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/.github/workflows/main.yml 0000664 0000000 0000000 00000003113 15143236361 0023076 0 ustar 00root root 0000000 0000000 name: CI
on:
push:
branches:
- main
- 'releases/*'
pull_request:
branches:
- '*'
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 11
- uses: eskatos/gradle-command-action@v1
with:
arguments: --stacktrace build
publish_artifacts:
name: Publish Snapshot Artifacts
needs: gradle
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'apiguardian-team/apiguardian' && (startsWith(github.ref, 'refs/heads/releases/') || github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
- name: 'Publish'
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
run: ./gradlew publish -x check
update_documentation:
name: Update Snapshot Documentation
needs: gradle
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'apiguardian-team/apiguardian' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
- name: 'Upload Documentation'
env:
GRGIT_USER: ${{ secrets.GH_TOKEN }}
run: ./gradlew gitPublishPush -x check
jtreg8-8.2.1+1+ds1/apiguardian/.gitignore 0000664 0000000 0000000 00000000257 15143236361 0020030 0 ustar 00root root 0000000 0000000 # Gradle
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Eclipse
.classpath
.settings/
.project
bin/
# IntelliJ
*.iml
*.ipr
*.iws
*.uml
.idea/
# Misc
*.log
jtreg8-8.2.1+1+ds1/apiguardian/LICENSE 0000664 0000000 0000000 00000026135 15143236361 0017050 0 ustar 00root root 0000000 0000000 Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
jtreg8-8.2.1+1+ds1/apiguardian/README.md 0000664 0000000 0000000 00000001546 15143236361 0017321 0 ustar 00root root 0000000 0000000 # @API Guardian
[](https://github.com/apiguardian-team/apiguardian/actions)
Library that provides the `@API` annotation that is used to annotate public types, methods, constructors, and fields within a framework or application in order to publish their status and level of stability and to indicate how they are intended to be used by consumers of the API.
## How to use it
The @API Guardian library is deployed to Maven Central. You can simply add it as a dependency:
### Apache Maven
```xml
org.apiguardianapiguardian-api1.1.2
```
### Gradle
```gradle
repositories {
mavenCentral()
}
dependencies {
compileOnlyApi("org.apiguardian:apiguardian-api:1.1.2")
}
```
jtreg8-8.2.1+1+ds1/apiguardian/build.gradle.kts 0000664 0000000 0000000 00000013345 15143236361 0021121 0 ustar 00root root 0000000 0000000 import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
plugins {
id("java")
id("eclipse")
id("idea")
id("maven-publish")
id("signing")
id("biz.aQute.bnd.builder") version "5.3.0"
id("net.nemerosa.versioning") version "2.14.0"
id("org.ajoberstar.git-publish") version "3.0.0"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
val buildTimeAndDate = OffsetDateTime.now()
val buildDate = DateTimeFormatter.ISO_LOCAL_DATE.format(buildTimeAndDate)
val buildTime = DateTimeFormatter.ofPattern("HH:mm:ss.SSSZ").format(buildTimeAndDate)
val builtByValue = project.findProperty("builtBy") ?: project.property("defaultBuiltBy")
val isSnapshot = project.version.toString().contains("SNAPSHOT")
val docsVersion = if (isSnapshot) "snapshot" else project.version
val docsDir = File(buildDir, "ghpages-docs")
val replaceCurrentDocs = project.hasProperty("replaceCurrentDocs")
description = "@API Guardian"
val moduleName = "org.apiguardian.api"
repositories {
mavenCentral()
}
java {
withJavadocJar()
withSourcesJar()
}
val moduleSourceDir = file("src/module/java")
tasks {
compileJava {
options.release.set(6)
}
val compileModule by registering(JavaCompile::class) {
source(moduleSourceDir)
destinationDir = file("$buildDir/classes/java/modules")
classpath = files(compileJava.map { it.classpath })
inputs.property("moduleName", moduleName)
inputs.property("moduleVersion", project.version)
options.release.set(9)
options.compilerArgs = listOf(
"--module-version", project.version as String,
"--module-source-path", moduleSourceDir.toString(),
"--patch-module", "$moduleName=${sourceSets.main.get().allJava.srcDirs.joinToString(":")}",
"--module", moduleName
)
}
jar {
fun normalizeVersion(versionLiteral: String): String {
val regex = Regex("(\\d+\\.\\d+\\.\\d+).*")
val match = regex.matchEntire(versionLiteral)
require(match != null) {
"Version '$versionLiteral' does not match version pattern, e.g. 1.0.0-QUALIFIER"
}
return match.groupValues[1]
}
manifest {
attributes(
"Created-By" to "${System.getProperty("java.version")} (${System.getProperty("java.vendor")} ${System.getProperty("java.vm.version")})",
"Built-By" to builtByValue,
"Build-Date" to buildDate,
"Build-Time" to buildTime,
"Build-Revision" to versioning.info.commit,
"Specification-Title" to project.name,
"Specification-Version" to normalizeVersion(project.version.toString()),
"Specification-Vendor" to "apiguardian.org",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "apiguardian.org",
"Bundle-Name" to project.name,
"Bundle-Description" to project.description,
"Bundle-DocURL" to "https://github.com/apiguardian-team/apiguardian",
"Bundle-Vendor" to "apiguardian.org",
"-exportcontents" to "org.apiguardian.api",
"Bundle-SymbolicName" to moduleName
)
}
from(files(compileModule.map { "${it.destinationDir}/${moduleName}" })) {
include("module-info.class")
}
}
javadoc {
(options as StandardJavadocDocletOptions).apply {
memberLevel = JavadocMemberLevel.PROTECTED
isAuthor = true
header = "@API Guardian"
addStringOption("Xdoclint:html,syntax,reference", "-quiet")
links("https://docs.oracle.com/en/java/javase/11/docs/api/")
}
}
named("sourcesJar") {
from("${moduleSourceDir}/${moduleName}") {
include("module-info.java")
}
}
named("javadocJar") {
from(javadoc.map { File(it.destinationDir, "element-list") }) {
// For compatibility with older tools, e.g. NetBeans 11
rename { "package-list" }
}
}
withType().configureEach {
from(rootDir) {
include("LICENSE")
into("META-INF")
}
}
val prepareDocsForUploadToGhPages by registering(Copy::class) {
dependsOn(javadoc)
outputs.dir(docsDir)
from("$buildDir/docs") {
include("javadoc/**")
}
from("$buildDir/docs/javadoc") {
// For compatibility with pre JDK 10 versions of the Javadoc tool
include("element-list")
rename { "api/package-list" }
}
into("${docsDir}/${docsVersion}")
filesMatching("javadoc/**") {
path = path.replace("javadoc/", "api/")
}
includeEmptyDirs = false
}
val createCurrentDocsFolder by registering(Copy::class) {
dependsOn(prepareDocsForUploadToGhPages)
enabled = replaceCurrentDocs
outputs.dir("${docsDir}/current")
from("${docsDir}/${docsVersion}")
into("${docsDir}/current")
}
gitPublishCommit {
dependsOn(prepareDocsForUploadToGhPages, createCurrentDocsFolder)
}
}
if (!isSnapshot) {
signing {
sign(publishing.publications)
}
}
nexusPublishing {
packageGroup.set(group.toString())
repositories {
sonatype()
}
}
publishing {
publications {
create("maven") {
from(components["java"])
pom {
name.set("${project.group}:${project.name}")
description.set("@API Guardian")
url.set("https://github.com/apiguardian-team/apiguardian")
scm {
connection.set("scm:git:git://github.com/apiguardian-team/apiguardian.git")
developerConnection.set("scm:git:git://github.com/apiguardian-team/apiguardian.git")
url.set("https://github.com/apiguardian-team/apiguardian")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("apiguardian")
name.set("@API Guardian Team")
email.set("team@apiguardian.org")
}
}
}
}
}
}
gitPublish {
repoUri.set("https://github.com/apiguardian-team/apiguardian.git")
branch.set("gh-pages")
contents {
from(docsDir)
into("docs")
}
preserve {
include("**/*")
exclude("docs/$docsVersion/**")
if (replaceCurrentDocs) {
exclude("docs/current/**")
}
}
}
jtreg8-8.2.1+1+ds1/apiguardian/gradle.properties 0000664 0000000 0000000 00000000165 15143236361 0021412 0 ustar 00root root 0000000 0000000 group = org.apiguardian
version = 1.1.2
defaultBuiltBy = @API Guardian Team
releaseBranch = master
jtreg8-8.2.1+1+ds1/apiguardian/gradlew 0000775 0000000 0000000 00000013216 15143236361 0017412 0 ustar 00root root 0000000 0000000 #!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
jtreg8-8.2.1+1+ds1/apiguardian/gradlew.bat 0000664 0000000 0000000 00000005313 15143236361 0020153 0 ustar 00root root 0000000 0000000 @rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
jtreg8-8.2.1+1+ds1/apiguardian/settings.gradle.kts 0000664 0000000 0000000 00000000272 15143236361 0021655 0 ustar 00root root 0000000 0000000 rootProject.name = "apiguardian-api"
require(JavaVersion.current().isJava11) {
"The @API Guardian build requires Java 11. Currently executing with Java ${JavaVersion.current()}."
}
jtreg8-8.2.1+1+ds1/apiguardian/src/ 0000775 0000000 0000000 00000000000 15143236361 0016623 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/main/ 0000775 0000000 0000000 00000000000 15143236361 0017547 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/main/java/ 0000775 0000000 0000000 00000000000 15143236361 0020470 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/main/java/org/ 0000775 0000000 0000000 00000000000 15143236361 0021257 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/main/java/org/apiguardian/ 0000775 0000000 0000000 00000000000 15143236361 0023543 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/main/java/org/apiguardian/api/ 0000775 0000000 0000000 00000000000 15143236361 0024314 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/main/java/org/apiguardian/api/API.java 0000664 0000000 0000000 00000010116 15143236361 0025567 0 ustar 00root root 0000000 0000000 /*
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apiguardian.api;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* {@code @API} is used to annotate public types, methods, constructors, and
* fields within a framework or application in order to publish their
* {@link #status} and level of stability and to indicate how they are intended
* to be used by {@link #consumers} of the API.
*
*
If {@code @API} is present on a type, it is considered to hold for all
* public members of the type as well. However, a member of such an annotated
* type is allowed to declare a {@link Status} of lower stability. For example,
* a class annotated with {@code @API(status = STABLE)} may declare a constructor
* for internal usage that is annotated with {@code @API(status = INTERNAL)}.
*
*
If {@code @API} is present on a package, it is considered to hold for all
* public types in its package. The same rules for lowered stability apply as
* if they were specified on a type.
*
* @since 1.0
*/
@Target({ TYPE, METHOD, CONSTRUCTOR, FIELD, PACKAGE })
@Retention(RUNTIME)
@Documented
public @interface API {
/**
* The current {@linkplain Status status} of the API.
*/
Status status();
/**
* The version of the API when the {@link #status} was last changed.
*
*
Defaults to an empty string, signifying that the since
* version is unknown.
*/
String since() default "";
/**
* List of packages belonging to intended consumers.
*
*
The supplied packages can be fully qualified package names or
* patterns containing asterisks that will be used as wildcards.
*
*
Defaults to {@code "*"}, signifying that the API is intended to be
* consumed by any package.
*/
String[] consumers() default "*";
/**
* Indicates the status of an API element and therefore its level of
* stability as well.
*/
enum Status {
/**
* Must not be used by any external code. Might be removed without prior
* notice.
*/
INTERNAL,
/**
* Should no longer be used. Might disappear in the next minor release.
*
*
This status is usually used in combination with the standard annotation
* {@link Deprecated @Deprecated} because that annotation is recognized by
* IDEs and the compiler. However, there are also cases where this status
* can be used on its own, for example when transitioning a {@link #MAINTAINED}
* feature to an {@link #INTERNAL} one.
*/
DEPRECATED,
/**
* Intended for new, experimental features where the publisher of the
* API is looking for feedback.
*
*
Use with caution. Might be promoted to {@link #MAINTAINED} or
* {@link #STABLE} in the future, but might also be removed without
* prior notice.
*/
EXPERIMENTAL,
/**
* Intended for features that will not be changed in a backwards-incompatible
* way for at least the next minor release of the current major version.
* If scheduled for removal, such a feature will be demoted to
* {@link #DEPRECATED} first.
*/
MAINTAINED,
/**
* Intended for features that will not be changed in a backwards-incompatible
* way in the current major version.
*/
STABLE;
}
}
jtreg8-8.2.1+1+ds1/apiguardian/src/module/ 0000775 0000000 0000000 00000000000 15143236361 0020110 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/module/java/ 0000775 0000000 0000000 00000000000 15143236361 0021031 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/module/java/org.apiguardian.api/ 0000775 0000000 0000000 00000000000 15143236361 0024653 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/apiguardian/src/module/java/org.apiguardian.api/module-info.java 0000664 0000000 0000000 00000000076 15143236361 0027737 0 ustar 00root root 0000000 0000000 module org.apiguardian.api {
exports org.apiguardian.api;
}
jtreg8-8.2.1+1+ds1/asmtools/ 0000775 0000000 0000000 00000000000 15143236361 0015411 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/.github/ 0000775 0000000 0000000 00000000000 15143236361 0016751 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/.github/workflows/ 0000775 0000000 0000000 00000000000 15143236361 0021006 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/.github/workflows/maven.yaml 0000664 0000000 0000000 00000001776 15143236361 0023013 0 ustar 00root root 0000000 0000000 name: Java CI
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
java-version: [ 17, 25 ]
fail-fast: false
name: ${{ matrix.os }} - Java ${{ matrix.java-version }} - Maven
steps:
- name: Checkout asmtools repo
uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.4
with:
maven-version: 3.8.4
- name: Build asmtools with Maven
run: |
set -x
pwd
ls
cd maven ;
bash mvngen.sh ;
mvn "--batch-mode" "--update-snapshots" "clean" "install"
mvn "--batch-mode" "--update-snapshots" "test"
jtreg8-8.2.1+1+ds1/asmtools/.gitignore 0000664 0000000 0000000 00000000360 15143236361 0017400 0 ustar 00root root 0000000 0000000 # Compiled class file
*.class
# Log file
*.log
# Package Files
*.jar
*.zip
*.tar.gz
*.tar
# virtual machine crash logs
hs_err_pid*
# Misc: Intellij Idea,Mac OS
/.idea/
/maven/.idea/
*.iml
.DS_Store
maven/target
maven/src
maven/pom.xml
jtreg8-8.2.1+1+ds1/asmtools/.hgtags 0000664 0000000 0000000 00000000527 15143236361 0016673 0 ustar 00root root 0000000 0000000 85d58e2683bfe2f70defd6ec10d377d84766ddd8 initial-openjdk
f201bb903e32f09e054f5fafc180508b9db67d00 6.0
c52c3f68bfba5ca97378e9e9df5fc1268ac9e481 7.0
f788f629bb40b3f3dd6d2cd25f3c9072568792de 7.0-b02
2931522b78a4a4842396ad61300853911caf4169 7.0-b04
b63cf0206a26c9cef5831aec217ed88a5ba09f5a 7.0-b05
5d0dc302199d510f0fb44763fbca8118d12f8ad8 7.0-b06
jtreg8-8.2.1+1+ds1/asmtools/.jcheck/ 0000775 0000000 0000000 00000000000 15143236361 0016716 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/.jcheck/conf 0000664 0000000 0000000 00000002367 15143236361 0017576 0 ustar 00root root 0000000 0000000 ;
; Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
;
; This code is free software; you can redistribute it and/or modify it
; under the terms of the GNU General Public License version 2 only, as
; published by the Free Software Foundation.
;
; This code is distributed in the hope that it will be useful, but WITHOUT
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
; version 2 for more details (a copy is included in the LICENSE file that
; accompanied this code).
;
; You should have received a copy of the GNU General Public License version
; 2 along with this work; if not, write to the Free Software Foundation,
; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
;
; Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
; or visit www.oracle.com if you need additional information or have any
; questions.
;
[general]
project=code-tools
repository=asmtools
jbs=codetools
[checks]
error=author,committer,whitespace,executable,symlink
[census]
version=0
domain=openjdk.org
[checks "whitespace"]
files=.*\.java$|.*\.c$|.*\.h$|.*\.cpp$|.*\.hpp$
jtreg8-8.2.1+1+ds1/asmtools/LICENSE 0000664 0000000 0000000 00000045512 15143236361 0016425 0 ustar 00root root 0000000 0000000 The GNU General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software is
covered by the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom to
distribute copies of free software (and charge for this service if you wish),
that you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs; and that you know you
can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny
you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for
a fee, you must give the recipients all the rights that you have. You must
make sure that they, too, receive or can get the source code. And you must
show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients to
know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will
individually obtain patent licenses, in effect making the program proprietary.
To prevent this, we have made it clear that any patent must be licensed for
everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms of
this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or
translated into another language. (Hereinafter, translation is included
without limitation in the term "modification".) Each licensee is addressed as
"you".
Activities other than copying, distribution and modification are not covered by
this License; they are outside its scope. The act of running the Program is
not restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made by
running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as
you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the
Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may
at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus
forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all of
these conditions:
a) You must cause the modified files to carry prominent notices stating
that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of
this License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the
most ordinary way, to print or display an announcement including an
appropriate copyright notice and a notice that there is no warranty (or
else, saying that you provide a warranty) and that users may redistribute
the program under these conditions, and telling the user how to view a copy
of this License. (Exception: if the Program itself is interactive but does
not normally print such an announcement, your work based on the Program is
not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License, and
its terms, do not apply to those sections when you distribute them as separate
works. But when you distribute the same sections as part of a whole which is a
work based on the Program, the distribution of the whole must be on the terms
of this License, whose permissions for other licensees extend to the entire
whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise the
right to control the distribution of derivative or collective works based on
the Program.
In addition, mere aggregation of another work not based on the Program with the
Program (or with a work based on the Program) on a volume of a storage or
distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1 and
2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above
on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to
give any third party, for a charge no more than your cost of physically
performing source distribution, a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of Sections 1
and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to
distribute corresponding source code. (This alternative is allowed only
for noncommercial distribution and only if you received the program in
object code or executable form with such an offer, in accord with
Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code
distributed need not include anything that is normally distributed (in either
source or binary form) with the major components (compiler, kernel, and so on)
of the operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the source
code from the same place counts as distribution of the source code, even though
third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies, or
rights, from you under this License will not have their licenses terminated so
long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it.
However, nothing else grants you permission to modify or distribute the Program
or its derivative works. These actions are prohibited by law if you do not
accept this License. Therefore, by modifying or distributing the Program (or
any work based on the Program), you indicate your acceptance of this License to
do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor to
copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of the
rights granted herein. You are not responsible for enforcing compliance by
third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution
of the Program by all those who receive copies directly or indirectly through
you, then the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose that
choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original
copyright holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In
such case, this License incorporates the limitation as if written in the body
of this License.
9. The Free Software Foundation may publish revised and/or new versions of the
General Public License from time to time. Such new versions will be similar in
spirit to the present version, but may differ in detail to address new problems
or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any later
version", you have the option of following the terms and conditions either of
that version or of any later version published by the Free Software Foundation.
If the Program does not specify a version number of this License, you may
choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status of
all derivatives of our free software and of promoting the sharing and reuse of
software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
One line to give the program's name and a brief idea of what it does.
Copyright (C)
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it
starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free
software, and you are welcome to redistribute it under certain conditions;
type 'show c' for details.
The hypothetical commands 'show w' and 'show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than 'show w' and 'show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
'Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General Public
License instead of this License.
"CLASSPATH" EXCEPTION TO THE GPL
Certain source files distributed by Oracle America and/or its affiliates are
subject to the following clarification and special exception to the GPL, but
only where Oracle has expressly included in the particular source file's header
the words "Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the LICENSE file that accompanied this code."
Linking this library statically or dynamically with other modules is making
a combined work based on this library. Thus, the terms and conditions of
the GNU General Public License cover the whole combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,
and to copy and distribute the resulting executable under terms of your
choice, provided that you also meet, for each linked independent module,
the terms and conditions of the license of that module. An independent
module is a module which is not derived from or based on this library. If
you modify this library, you may extend this exception to your version of
the library, but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version.
jtreg8-8.2.1+1+ds1/asmtools/README.html 0000664 0000000 0000000 00000035476 15143236361 0017253 0 ustar 00root root 0000000 0000000
README - AsmTools - Version 9.1
AsmTools is a software package containing a collection of tools that you can use to encode and decode a Java class file, without using a Javac compiler.
You can use AsmTools to create class files which can not normally be produced by a compiler. These class files can be used during the
development process to test the compliance of a Virtual Machine (VM) to its specification.
These release notes contain information about the ASM Tools version 9.1.
See the (
CodeTools project)
AsmTools OpenJDK project page for more information about AsmTools.
To install the AsmTools, simply unzip the asmtools-9.1.zip
distribution file in the directory of your choice. Optionally, you may
wish to define an environment variable (ASMTOOLS_HOME) to point to this
location for your convenience.
This section lists the components under the base subdirectory structure
(asmtools-9.1/)
that is created when you unzip the AsmTools distribution archive during
installation.
Note* If
you are creating a local copy of AsmTools, you can not move the /lib
folder to a different location. AsmTools relies on the relative
location of this folder.
The AsmTools open source project was created in order to develop a community that will improve it, further the development of Java assembly tools, and use Java assemblers to develop test suites. We encourage you to browse, download, contribute, and get involved.
The sources for ASM Tools 9.1 and later is available via the community
OpenJDK project. The sources are stored
and accessed through a Mercurial repository, which the public may access in a
read-only fashion. Committing to changes to the sources is accomplished by
first contributing through a proxy developer to establish ones self, which can
then lead to rights to contribute directly. More information can be found on
the OpenJDK Projects landing page.
The general form for obtaining a copy of the current source tree is:
% git clone https://github.com/openjdk/asmtools
This places a copy of the entire source tree in the asmtools directory. From
that directory, you can then view and build the sources, as described in the next
section. Note that this copy is of the development version of the sources,
you may need to extract a different revision if you want a copy from a specific
period of time.
Building the sources requires Ant version 1.8 or later (1.10.13 is current at the
time of writing), and the built-in build is compatible with using an IDE.
The sources are designed for Java 17 and if you invoke ant with this
runtime, your chance of encountering an abnormal conditions due to your runtime
or compiler (or javadoc) version.
General requirements:
ant, version 1.8 or later
Java 17 runtime and compiler (minimum and recommended)
10MB free disk space (3MB for source tree, 7MB for build output)
The general steps to take a build from source from the command line:
Output appears in a directory above (one above <topdir>),
such as: ../../asmtools-9.1-build/
A common variation of the build command to force ant to use a particular
installation of Java on your machine:
# JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home ANTHOME=/usr/share/ant ant
This example for common *nix shells (zsh, bash, sh), alter it as needed for your
command environment. You can test your invocation of ant by running it with
the -diagnostics flag, where it will indicate which Java it is
using.
The build file itself is build/build.xml, this is the file you can
specify in your IDE for building.
jtreg8-8.2.1+1+ds1/asmtools/README.md 0000664 0000000 0000000 00000005111 15143236361 0016666 0 ustar 00root root 0000000 0000000 # OpenJDK AsmTools
The AsmTools open source project is used to develop tools for the production of proper and improper Java `.class` files. AsmTools are being opened in order to facilitate a community of Java .class file production for various testing and other OpenJDK development applications.
Tool usage is covered in the Using AsmTools documentation.
AsmTools consist of a set of (Java class file) assembler/disassemblers:
+ **Jasm/Jdis** - an assembler language that provides a Java-like declaration of member signatures, while providing Java VM specification compliant mnemonics for byte-code instructions. Jasm also provides high-level syntax for constructs often found within classfile attributes. Jasm encoded tests are useful for sequencing byte codes in a way that Javac compiled code might not normally sequence byte-codes.
+ **JCod/JDec** - an assembler language that provides byte-code containers of class-file constructs. JCod encoded tests are useful for testing the well-formedness of class-files, as well as creating collections within a class-file construct that might be size-bounded by a normal Java compiler. JCod can also be used to 'fuzz' class files in a methodical way that respects class-file constructs.
AsmTools are completely reflexive - Java binary (.class) files may be disassembled into textual representations, which in turn can be assembled back to the same binary file.
AsmTools are developed to support the latest class file formats, in lock-step with JDK development.
Other open source Java assembler tools and binary classfile frameworks exist. They can be used for the purpose of synthesizing classfiles, however:
- they typically are designed to enforce the limits imposed by the VM specification of the class file format. They are not designed to produce classes that violate those limits.
- other assembler tools may not necessarily follow strict Java mnemonics as defined in the Java VM spec.
- other assembler tools may not stay in lock-step with the current generation of the JDK and VM specifications.
- class file libraries are harder to use for simple manipulations of any given class file. Typically, one has to create a program in that framework to parse and modify a class for a specific change to a given class.
The AsmTools open source project is part of the [Code Tools Project](http://openjdk.java.net/projects/code-tools/ "Code Tools Project"). It exists to promote a community that will improve it, further its development, and use it to develop test suites. We encourage you to browse, download, contribute, and get involved.
jtreg8-8.2.1+1+ds1/asmtools/build/ 0000775 0000000 0000000 00000000000 15143236361 0016510 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/build/build.properties 0000664 0000000 0000000 00000002630 15143236361 0021726 0 ustar 00root root 0000000 0000000 # Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
# Compile in verbose mode
javac.verbose=false
# Compile in debug mode
javac.debug=true
# Compile with deprecation flag
javac.deprecation=false
javac.release.version=17
# path to output directory
BUILD_DIR = ../../asmtools-${PRODUCT_VERSION}-build
jtreg8-8.2.1+1+ds1/asmtools/build/build.xml 0000664 0000000 0000000 00000043136 15143236361 0020340 0 ustar 00root root 0000000 0000000
Usage:
ant <TARGET> -D<OPTIONS>
where TARGET is:
all cleans, tests, and builds if no issues are found.
build (default): builds all binaries, doc and distributions.
clean: removes all generated files and directories.
cleanAndBuild: cleans, then builds the project.
help: prints a usage message (this message).
Other values for TARGET are:
devbuild: produces binaries and javadocs.
javadoc: produces javadocs.
test: runs tests.
cleanAndTest: cleans test artifacts, then tests the project.
clean-test: cleans tests artifacts.
...${line.separator}${line.separator}
Current Java version is ${ant.java.version}
The build should be started by Java 17 or above
SOURCE="git:${git.revision}"
VERSION="${PRODUCT_VERSION}_${PRODUCT_BUILDNUMBER}"
VERSION_DATE="${build.date}"
MILESTONE="${PRODUCT_MILESTONE}"
jtreg8-8.2.1+1+ds1/asmtools/build/productinfo.properties 0000664 0000000 0000000 00000002621 15143236361 0023163 0 ustar 00root root 0000000 0000000 # Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
# Path to JDK will be used to compile sources
# Product info
PRODUCT_NAME =asmtools
PRODUCT_JAR_NAME =asmtools.jar
PRODUCT_VERSION =9.1
PRODUCT_MILESTONE =ea
PRODUCT_BUILDNUMBER =01
PRODUCT_NAME_LONG =Java Assembler Tools
jtreg8-8.2.1+1+ds1/asmtools/docs/ 0000775 0000000 0000000 00000000000 15143236361 0016341 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/docs/Class00.jasm 0000664 0000000 0000000 00000000732 15143236361 0020424 0 ustar 00root root 0000000 0000000 package org/openjdk/asmtools/source00;
public super class Class00 version 67:0
{
public Method "":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method java/lang/Object."":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V"
stack 0 locals 1
{
return;
}
SourceFile "Class00.java";
} // end Class org/openjdk/asmtools/source00/Class00 compiled from "Class00.java"
jtreg8-8.2.1+1+ds1/asmtools/docs/Class00.java 0000664 0000000 0000000 00000000163 15143236361 0020411 0 ustar 00root root 0000000 0000000 package org.openjdk.asmtools.source00;
public class Class00 {
public static void main(String argv[]) {
}
}
jtreg8-8.2.1+1+ds1/asmtools/docs/Class00_1.jasm 0000664 0000000 0000000 00000000745 15143236361 0020650 0 ustar 00root root 0000000 0000000 file Cls01
package org/openjdk/asmtools/source00;
public super class Class00 version 67:0
{
public Method "":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method java/lang/Object."":"()V";
return;
}
public static Method main:"([Ljava/lang/String;)V"
stack 0 locals 1
{
return;
}
SourceFile "Class00.java";
} // end Class org/openjdk/asmtools/source00/Class00 compiled from "Class00.java"
jtreg8-8.2.1+1+ds1/asmtools/docs/UsingTools.md 0000664 0000000 0000000 00000033301 15143236361 0020771 0 ustar 00root root 0000000 0000000 ## Chapter 1
### Java Assembler Tools (AsmTools) User’s Guide
---
### Using the AsmTools
This chapter describes general principles and techniques for using the AsmTools.
If no command-line options are provided, or they are invalid, the tools display
error messages and usage information. To get the help message, launch AsmTools
without parameters:
```bash
java -jar asmtools.jar
```
The help system describes how to use all the AsmTools components and contains
the following topics described in this chapter.
- [Assemblers and Disassemblers](#BADGCIGA)
- [JASM vs JCOD](chapter2.html#BADGCIGB)
- [Tool Usage](#BADCEIIF)
- [ASMTools (Launcher)](BADCEABC)
- [JASM](#BADEFIIJ)
- [JDIS](#BADCBFCE)
- [JCODER](#BADIFAIE)
- [JDEC](#BADHJAHI)
---
### Assemblers and Dissassemblers
Assembly and disassembly are reflexive operations. One tool’s output can be fed
into another to reproduce the same file.
```bash
java -jar asmtools.jar jdec Foo.class # produces Foo.jcod
java -jar asmtools.jar jcoder Foo.jcod # produces Foo.class
java -jar asmtools.jar jdis Foo.class # produces Foo.jasm
java -jar asmtools.jar jasm Foo.jasm # produces Foo.class
```
For a given `foo.class`, the result of disassembly followed by reassembly is the
same `foo.class`.
---
### JASM vs JCOD
Which format to use depends on the task you are trying to do.
We can describe some generalizations of when you might wish to use the `JASM` format versus the `JCOD` format.
#### JASM
The biggest difference between the two formats is that `JASM` specifically focuses on representing byte-code instructions in the VM format
(while providing minimal description of the structure of the rest of the class file).
Generally, `JASM` is more convenient for semantic changes, like change to instruction flow.
Typical JASM use cases:
- Producing invalid classes in which two methods have the same signature
- Producing invalid class references that use illegal types
- Generating invalid classes with missing or removed instructions
- Inserting instrumentation or profiling instructions into methods
- Creating classes in which language keywords are used as identifiers
- Verifying that two classes produced by different compilers are equivalent
#### JCOD
`JCOD` provides good support for describing the structure of a class file
(as well as writing incorrect bytes outside of this structure),
and provides no support for specifying byte-code instructions (simply raw bytes for instructions).
`JCOD` is typically used for VMs to test Well-formedness of class files (e.g. extra or missing bytes),
boundary issues, constant-pool coherence, constant-pool index coherence, attribute well-formedness, etc.
Typical JCOD use cases:
- Examining specific parts of a class file, such as:
- the constant pool (for dependency analysis)
- constant values
- inheritance chains (superclasses)
- interface implementation and resolution
- Producing malformed or structurally invalid class files for JVM testing
- Validating class-file well-formedness rules
- Testing boundary conditions and structural constraints
- Verifying attribute structure and consistency
---
### Tool Usage
AsmTools consists of the following utilities:
- [jasm](#BADEFIIJ) – Generates class files from `JASM`
- [jdis](#BADCBFCE) – Disassembles class files into `JASM`
- [jcoder](#BADIFAIE) – Generates class files from `JCOD`
- [jdec](#BADHJAHI) – Disassembles class files into `JCOD`
Each utility can be invoked as:
```bash
java -jar asmtools.jar UTILITY [options] File1 ...
```
or
```bash
java -cp asmtools.jar com.sun.asmtools.UTILITY.Main [options] File1 ...
```
Each utility supports own set of options.
---
**Note**: See the following sections for the options associated with each tool.
---
### ASMTools (Launcher)
The `asmtools.jar` launcher provides a single entry point to run one of the AsmTools utilities (`jasm`, `jdis`, `jcoder`, or `jdec`)
and to display global help/version information.
**Usage**:
```text
java -jar asmtools.jar run jasm, jdis, jcoder, or jdec tool
or: java -jar asmtools.jar -?|-h|-help print Help (this message) and exit
or: java -jar asmtools.jar -version print version information and exit
use -dls switch to return the ancient dual stream logging
```
---
### JASM
`JASM` assembles a `.jasm` source file, written according to the [JASM Specification](JASM_SPEC), into a `.class` file
for use with a Java Virtual Machine.
**Usage**:
```text
java -jar asmtools.jar jasm [options] |-
```
or
```text
java -cp asmtools.jar org.openjdk.asmtools.jasm.Main [options] |-
```
**Note**: if `-` is provided, `` is used as the input stream.
#### Options:
```text
-d Specify where to place generated class files, otherwise
-w Specify where to place generated class files, without considering the classpath, otherwise
-nowrite Do not write generated class files
-nowarn Do not print warnings
-strict Consider warnings as errors
-cv Set operating class file version if not specified in the source file (by default 45.3)
-fixcv Override class file version in source file(s)
-fixcv Update class file version to major.minor if file's version is below the threshold()
-t Print debug, trace information
-v Print additional information
-version Print the jasm version
```
#### Notes:
1. **Class-file generation behavior**
The `-nowrite` option always suppresses generation of the `.class` file.
Without `-nowrite`, warnings prevent class-file generation only when `-strict` is specified; otherwise, the class file is written.
This chapter describes JASM syntax, and how to encode class files
using this
syntax. Jasm is a java
assembler that accepts text in the JASM
format and produces a .class file for use
with a Java Virtual Machine. Jasm's
primary
use
is
as
a
tool for producing specialized tests for testing a JVM
implementation
This chapter describes JASM syntax in the following sections:
JASM syntax can come in one of two variations: short-form or
verbose-form. Short form uses Java-style names to refer to items
in a constant-pool. Verbose form uses explicit constant-pool
indexes to refer to items in the constant pool. The normal output
from JDIS produces jasm files in the short-form. Using the -g
option for JDIS (ie. jdis -g file.class) produces JASM source in
the verbose-form.
The source text file can be free form (newlines are considered
blanks)
and may contain Java-style commenting.
The first line of a JASM file represents the name of the resulting
file in the destination directory. This name does not affect the
content of
the resulting file. This line has two forms:
file FILENAME
or
class CLASSNAME
In the latter case, extension .class will be added to
form FILENAME. Jasm's -d option allows you to define the
destination
directory. A list of structured dataWriter items follows the class name. The
length (in bytes) of each item
is determined by its representation.
Description formats
TERM1|TERM2
TERM1 or TERM2 (not both)
[TERM]
TERM is optional
TERM...
TERM repeated 1 or more times
[TERM...]
TERM repeated 0 or more times
"sequence of"
all the following terms are mandatory, in the order given.
"set of"
any of following terms, or none of them,
may appear in any order. However, repetitions are not allowed.
"list of"
any of following terms, or none of them,
may appear in any sequence. If more than one term appear, they are
separated by commas (',')
Lexical Structure
The source text file can be free form (newlines, tabs, and blank
spaces are equivalent). Additionally, the source may contain standard
Java
and C++ comments.
STRING, NUMBER, and IDENT
are treated the same as in
the Java Language Specification. One difference is that LETTERs include
also `/', `<', `>', `(', and `)' .
STRING:
" [ STRING_CHARACTER... ] "
NUMBER:
DIGIT...
IDENT:
LETTER [ LETTER_OR_DIGIT ...]
ACCESS (depends on the context):
set of
abstract final interface native private protected public
static super synchronized transient volatile deprecated synthetic
bridge varargs
Not all access bits make sense for all declarations: for example,
the
"super" and "interface" access flags are applied to classes only.
If an access bit is used improperly,
the assembler prints a warning, but places the bit in the access
set.
Note that deprecated and synthetic
keywords
are not translated to access flags in the Java sense.
For these jasm generates a corresponding Deprecated
or Synthetic attributes instead of access bits. The synthetic
access flag is used to mark compiler generated
members not
seen in the source (for example, a field reference to an anonymous
outer class).
TAG: one of
int float long double Asciz String class Field Method
NameAndType InterfaceMethod MethodType MethodHandle InvokeDynamic Dynamic
Local names represent labels, rangePC-labels and local variables. Their
scope is constrained by method parenthesis.
LOCAL_NAME:
IDENT
CONSTANT_INDEX:
#NUMBER
Each CONSTANT_INDEX represents a reference into the constant pool
at the specified location.
The extends CONSTANT_CELL(class) clause places the
"super" element of the
class file. The implements INTERFACES clause places the
table of interfaces.
Since the assembler does not distinguish interfaces and ordinary
classes
(the only difference is one access bit), the table of interfaces of an
interface class must be declared with implements keyword,
and not extends, as in Java language.
Note:The last two rules allow TOP_LEVEL_COMPONENT
to appear in any order and number. For example, you can split constant
pool table into several parts, mixing constants and method
declarations.
Package declaration can appear only once in source file.
CLASS_FILE: sequence of
PACKAGE_DECLARATION CLASS...
MODULE_FILE:
MODULE...
SOURCE_FILE:
MODULE_FILE|CLASS_FILE
The Constant Pool and Constant Elements
A CONSTANT_CELL refers to an element in the constant
pool.
It may refer to the element either by its index or its value:
CONSTANT_CELL:
CONSTANT_INDEX TAGGED_CONSTANT_VALUE
Generic rule for TAGGED_CONSTANT_VALUE is:
TAGGED_CONSTANT_VALUE:
[TAG] CONSTANT_VALUE
A TAG may be omitted when the context only allows one kind of a tag.
For example, the argument of an anewarray instruction
should be a CONSTANT_CELL which represents a class, so
instead of
anewarray class java/lang/Object
one may write:
anewarray java/lang/Object
It is possible to write another tag, e.g.:
anewarray String java/lang/Object
However, the resulting program will be incorrect.
Another example of an implicit tag (eg. a context which implies tag)
is the header of a class declaration. You may write:
aClass { }
which is equivalent to:
class aClass { }
Below, the tag implied by context will be included in the rules, e.g.:
CONSTANT_VALUE(int).
The exact notation of CONSTANT_VALUE depends on the
(explicit or implicit) TAG.
Note
When the JASM parser encounters an InvokeDynamic constant, it creates
an entry in
the BootstrapMethods attribute (the BootstrapMethods
attribute is produced if it
has not already been created). The entry contains a reference to the MethodHandle
item
in the constant pool, and, optionally, a sequence of references to
additional static
arguments (ldc-type constants) to the bootstrap
method
INVOKESUBTAGs for MethodHandle and (const) InvokeDynamic are defined as
follows and can be presented as either an index or a tag:
INVOKESUBTAG: [INVOKESUBTAG_INDEX]
REF_GETFIELD
[1]
REF_GETSTATIC
[2]
REF_PUTFIELD
[3]
REF_PUTSTATIC
[4]
REF_INVOKEVIRTUAL
[5]
REF_INVOKESTATIC
[6]
REF_INVOKESPECIAL
[7]
REF_NEWINVOKESPECIAL
[8]
REF_INVOKEINTERFACE
[9]
Static arguments for an InvokeDynamic constant are defined as follows:
INVOKEDYNAMIC_STATIC_ARGUMENTS:
INVOKEDYNAMIC_STATIC_ARG ',' ...
INVOKEDYNAMIC_STATIC_ARG: (one of)
INVOKEDYNAMIC_STATIC_ARG_CONSTANT_VALUE
INVOKEDYNAMIC_STATIC_ARG_CONSTANT_VALUE:
int
INTEGER
long
[INTEGER|LONG]
float
[FLOAT|INTEGER]
double
[FLOAT|DOUBLE|INTEGER|LONG]
class
CONSTANT_NAME
String
CONSTANT_NAME
MethodHandle
INVOKESUBTAG:CONSTANT_FIELD
MethodType
CONSTANT_NAME
INTEGER, LONG, FLOAT, and DOUBLE
correspond to IntegerLiteral
and FloatingPointLiteral as described in
The
Java
Language
Specification. If a double-word constant (LONG
or DOUBLE) is represented with a single-word value (INTEGER
or FLOAT, respectively), single-word value
is simply promoted to double-word, as described in
The
Java
Language
Specification. If floating-point constant (FLOAT
or DOUBLE) is represented with an integral value
(INTEGER or LONG, respectively),
the result depends on whether the integral number is preceded with the
keyword
"bits". If "bits" is not used, the result is a floating-point number
closest in value to the decimal number. If the keyword "bits" is used,
the floating-point constant takes bits of the integral value without
conversion.
Thus,
float 2;
means the same as
float 2.0f;
and the same as
float bits 0x40000000;
while
float bits 2;
actually means the same as
float bits 0x00000002;
and the same as
float 2.8026e-45f
CONSTANT_NAME:
CONSTANT_INDEX
EXTERNAL_NAME
EXTERNAL_NAME:
IDENT STRING
External names are names of class, method, field, or type, which stay
in resulting .class file, and may be represented both by
IDENT or by STRING (which is useful when
name contains non-letter characters).
NAME_AND_TYPE:
CONSTANT_INDEX CONSTANT_NAME:CONSTANT_NAME
In this second example, the first CONSTANT_NAME denotes
the name of a field and second denotes its type.
CONSTANT_FIELD:
CONSTANT_INDEX [CONSTANT_NAME.]NAME_AND_TYPE
In this third example, CONSTANT_NAME denotes to the class
of a field. If CONSTANT_NAME is omitted, the current
class is
assumed.
Constant Declarations
Constant declarations are demonstrated in the examples below:
public static Field field1:I = int 1234, field2:"Ljava/lang/String;", field3:"Ljava/util/List;":"Ljava/util/List<+Ljava/lang/String;>" ;
Access bits (public and static) are applied both to field1 and
field2.
The EXTERNAL_NAME denotes the name of the field, CONSTANT_NAME
denotes its type, TAGGED_CONSTANT_VALUE
denotes initial value.
The meaning of the THROWS clause is the same as in Java
Language Specification - it forms Exceptions attribute of a method.
Jasm itself does not use this attribute in any way.
STACK_SIZE:
stack NUMBER
The NUMBER denotes maximum operand stack size of the
method.
LOCAL_VAR_SIZE:
locals NUMBER
The NUMBER denotes number of local variables of the
method. If omitted, it is calculated by assembler according to the
signature of
the method and local variable declarations.
Jasm allows for a NUMBER
(which is ignored) at the beginning of each line. This is allowed in
order to remain consistent with the jdis disassembler. Jdis puts line
numbers in disassembled code that may be reassembled using Jasm
without any additional modifications.
INSTRUCTION:
OPCODE [ARGUMENTS]
ARGUMENTS: list of
ARGUMENT
ARGUMENT:
NUMBER LABEL LOCAL_VARIABLE TRAP_IDENT CONSTANT_CELL
SWITCHTABLE TYPE
LABEL:
NUMBER IDENT
LOCAL_VARIABLE:
NUMBER IDENT
TRAP_IDENT:
IDENT
TYPE:
NUMBER boolean byte char int float long double class
SWITCHTABLE:
{ [NUMBER:LABEL...] [default:LABEL] }
SWITCHTABLE example: Java_text
switch (x) { case 11: x=1; break; case 12: x=2; break; default: x=3; }
OPCODE is any mnemocode from the instruction set.
If mnemocode needs an ARGUMENT, it cannot be omitted.
Moreover, the kind (and number) of the argument(s) must match the kind
(and number) required by the mnemocode:
InvokeDynamic instructions are instructions that allow
dynamic binding of methods to a call site. These instructions in JASM
form are rather complex, and the JASM assembler does some of the
necessary work to create a BootstrapMethods attribute for
entries of binding methods.
class Test
version 51:0
{
Method m:"()V"
stack 0 locals 1
{
invokedynamic InvokeDynamic REF_invokeSpecial:bsmName:"()V" // information about bootstrap method
:methName:"(I)I" // dynamic call-site name ("methName") plus the argument and return types of the call ("(I)I")
int 1, long 2l; // optional sequence of additional static arguments to the bootstrap method (ldc-type constants)
}
} // end Class Test
This JASM code has an invokedynamic instruction of the
form: invokedynamic InvokeDynamic (CONSTANT_CELL(INVOKEDYNAMIC))
where the INVOKEDYNAMIC constant is represented as specified
Method #15:#12 stack 0 locals 1 { 0: invokedynamic InvokeDynamic #1; // InvokeDynamic REF_invokeSpecial:Test3.bsmName:"()V":name:"(I)I" int 1, long 2l; }
BootstrapMethod #19 #8 #3;
} // end Class Test3
In this example, const #1 = InvokeDynamic 0:#11; is
the
InvokeDynamic constant that refers to BootstrapMethod at index '0' in
the BootstrapMethods Attribute (BootstrapMethod #19 #8
#3; which refers to the MethodHandle at const #19,
plus 2 other static args (at const #8 and const #3).
Pseudo Instructions
Pseudo instructions are 'assembler
directives', and not really instructions (in the VM sense) They
typically come in two forms: Code-generating Pseudo-Instructions,
and Attribute-Generating Pseudo-Instructions.
Code-Generating Pseudo-Instructions
The bytecode directive
instructs the assembler to put a collection of raw bytes into the code
attribute of a methodK
bytecode NUMBERS
NUMBERS is list of NUMBERs (divided by COMMA).
Insert bytes in place of the instruction. May have any number
of numeric arguments, each of them to be converted into a byte and
inserted in method's code.
Attribute-Generating Pseudo-Instructions
The rest of pseudo_instructions do not produce any bytecodes, and
are
used to form tables: local variable table, exception table,
Stack Maps, and Stack Map Frames. Line Number Tables can not be
specified, but they are constructed
by the assembler itself.
Local Variable Table Attribute Generation
var LOCAL_VARIABLE
Starts local variable range
endvar LOCAL_VARIABLE
Ends local variable range. LOCAL_VARIABLE means name or index
of local variable table entry.
Example:
static void main (String[] args) { Tester inst = new Tester(); inst.callSub(); }
To generate exception table, three pseudo-instructions are used.
try TRAP_IDENT
Starts rangePC range
endtry TRAP_IDENT
Ends rangePC range
catch TRAP_IDENT CONSTANT_CELL(class)
Starts exception handler.
TRAP_IDENT represents the
name or number of an exception table entry. CONSTANT_CELL
in "catch" pseudo_instruction means
catch
type. Each exception table entry contains 4 values:start-pc, end-pc,
catch-pc, catch-type. In jasm, each entry is denoted with some (local)
identifier, as an example: TRAP_IDENT.
To set start-pc, place "try TRAP_IDENT"
before the instruction with the desirable program counter.
Similarly, use "endtry TRAP_IDENT" for
end-pc and "catch TRAP_IDENT, catch-type" for catch-pc and catch-type
(which is usually a constant pool reference).
Try, endtry, and catch pseudoinstructions may be placed in any order.
The order of entries in exception table is significant (see JVM
specification). However, the only way to control this order is to
place catch-clauses in appropriate
textual order: assembler adds an entry in the exception table each
time it encounters a catch-clause.
try R1, R2; // single "try" or "endtry" can start several regions new class java/lang/Exception; dup; ldc String "EXC"; invokespecial java/lang/Exception.<init>:"(Ljava/lang/String;)V"; athrow; endtry R1; catch R1 java/lang/NullPointerException; // only one "catch" per entry allowed astore_1; aload_1; athrow; catch R1 java/lang/Exception; // same region (R1) can appear in different catches astore_1; aload_1; athrow; endtry R2; catch R2 java/lang/Throwable; astore_1; aload_1; athrow;
StackMap Table Attribute Generation
Stack Maps are denoted by the pseudo-op opcode stack_map,
and they can be identified by three basic items:
public Method
"<init>":"()V"
stack 2 locals 1
{
...
stack_map
class
java/lang/Object;
nop;
return;
}
Example 3 (NewObject):
public Method
"<init>":"()V"
stack 2 locals 1
{
...
stack_map at L5;
nop;
return;
}
StackFrameType Table Attribute Generation
StackFrameTypes are similar assembler directives as StackMap.
These directives can appear anywhere in
the code, and the assembler will collect them to produce a
StackFrameType attribute.
Member annotations are a subset of the basic annotations support
provided in JDK 5.0 (1.5). These are annotations that
ornament Packages, Classes, and Members either visibly (accessible at
runtime) or invisibly (not accessible at
runtime). In JASM, visible annotations are denoted by the token @,
while
invisible
annotations
are
denoted
by the token @-.
The '@+' token identifies a
Runtime Visible Annotation, where the '@-'
token identifies a Runtime Invisible Annotation.
ANNOTATION_NAME:
IDENT
ANNOTATION_VALUE_DECLARATIONS: list
of (comma separated)
ANNOTATION_VALUE_DECLARATION
ANNOTATION_VALUE_DECLARATION:
[ANNOTATION_VALUE_IDENT=] [ANNOTATION_VALUE]
ANNOTATION_VALUE_IDENT:
IDENT
ANNOTATION_VALUE:
ANNOTATION_VALUE_PRIMITIVE | Array of
ANNOTATION_VALUE_PRIMITIVE
ANNOTATION_VALUE_PRIMITIVE:
PRIMITIVE_TYPE | STRING | CLASS | ENUM |
ANNOTATION_DECLARATION
CLASS:
class CONSTANT_CELL(class)
ENUM:
enum CONSTANT_CELL(class) CONSTANT_CELL(string) (where
string is Enum type name)
PRIMITIVE_TYPE:
BOOLEAN | BYTE | CHAR | SHORT | INTEGER | LONG | FLOAT |
DOUBLE
Note
Types (Boolean, Byte, Char, and Short) are
normalized into Integer's within the constant pool.
Annotation values with these types may be identified
with a keyword in front of an integer value.
Other primitive types are parsed according to normal
prefix and suffix
conventions
(eg. Double = xxx.xd, Float = xxx.xf, Long = xxxL).
Strings are identified and delimited by '"'
(quotation marks).
Keywords 'class' and 'enum' identify those annotation
types explicitly. Values within classes and enums may
either be identifiers (strings) or Constant Pool IDs.
Annotations specified as the value of an Annotation field
are identified by the JASM annotation keywords '@+' and '@-'.
Arrays are delimited by '{' and '}' marks, with individual elements
delimited by ',' (comma).
@+java/lang/Deprecated { since = "9", forRemoval = boolean true }
moduleContent my.moduleContent version 53:0 { ...
Note:
JASM does not enforce the annotation value declarations like a
compiler would. It only checks to see that an annotation
structure is well-formed.
Type Annotations
Member annotations are a subset of the basic annotations support
provided in JDK 7.0 (1.7). These are annotations that
ornament Packages, Classes, and Members either visibly (accessible at
runtime) or invisibly (not accessible at
runtime). In JASM, visible annotations are denoted by the token @T+,
while
invisible
annotations
are
denoted
by the token @T-.
Parameter annotations are another subset of the basic annotations
support provided in JDK 5.0 (1.5). These are annotations that
ornament Parameters to methods either visibly (accessible at runtime)
or invisibly (not accessible at
runtime). In JASM, visible parameter annotations are denoted by the
token @+, while invisible parameter annotations are denoted
by the token @-.
Parameter names come from an attribute introduced in JDK 8.0
(1.8). These are fixed parameter names that are used to ornament
parameters on methods. In Jasm, parameter names are identified by
the token # followed by { } braclets
Note: The first
two parameters are named ('P0'- 'P3'). Since this is a compiler
controlled option, there is no way to specify parameter naming in Java
source.
super public class MyClass2 version 50:0 { ...
public Method doSomething:"(IZIZ)I" stack 2 locals 5
Default annotations are another subset of the basic
annotations
support provided in JDK 5.0 (1.5). These are annotations that
ornament Annotations either visibly (accessible at runtime)
or invisibly (not accessible at
runtime). Default annotations specify a default value for a given
annotation field.
These instructions takes 2 bytes: prefix (254 for non-privileged
variant and 255 for privileged) and the opcode itself.
These instructions can be coded in assembler in 2 ways:
as single mnemocode identical to the description or
using "priv" and "nonpriv" instructions followed with an integer
representing the opcode.
jtreg8-8.2.1+1+ds1/asmtools/docs/jasm.md 0000664 0000000 0000000 00000163454 15143236361 0017632 0 ustar 00root root 0000000 0000000
# JASM Syntax
This chapter describes _JASM syntax_, and how to encode class files using this syntax. _Jasm_ is a java
assembler that accepts text in the JASM format and produces a `.class` file for use with a Java Virtual Machine.
_Jasm_'s primary use is as a tool for producing specialized tests for testing a JVM implementation.
This chapter describes JASM syntax in the following sections:
- [General Class Structure](#general-class-structure)
- [General Module Structure](#general-module-structure)
- [General Source File Structure](#general-source-file-structure)
- [The Constant Pool and Constant Elements](#the-constant-pool-and-constant-elements)
- [Constant Declarations](#constant-declarations)
- [Field Variables](#field-variables)
- [Method Declarations](#method-declarations)
- [Instructions](#instructions)
- [Pseudo Instructions](#pseudo-instructions)
- [Inner Class Declarations](#inner-class-declarations)
- [Annotation Declarations](#annotation-declarations)
- [Member Annotations](#member-annotations)
- [Synopsis](#synopsis)
- [Examples](#examples)
- [Type Annotations](#type-annotations)
- [Synopsis](#synopsis-1)
- [Parameter Names and Parameter Annotations](#parameter-names-and-parameter-annotations)
- [Synopsis](#synopsis-2)
- [Examples](#examples-1)
- [Default Annotations](#default-annotations)
- [Synopsis](#synopsis-3)
- [Examples](#examples-2)
- [Module properties](#module-properties)
- [Requires](#requires)
- [Exports](#exports)
- [Opens](#opens)
- [Uses](#uses)
- [Provides](#provides)
- [PicoJava Instructions](#picojava-instructions)
---
## JASM Syntax Overview
JASM syntax comes in two forms: short-form and verbose-form:
1. **Short-form:** Uses Java-style names to refer to items in the constant-pool.
2. **Verbose-form:** Uses constant-pool indexes to explicitly refer to items.
By default, the **JDIS** tool outputs short-form JASM files. To generate verbose-form output, use the `-g` option, like this:
``` shell
java -jar asmtools.jar jdis -g
```
## File Naming in JASM
A JASM file can start with a line specifying the name of the output file. This does not affect the file’s content but determines the file name. The first line can be one of these:
- `file FILENAME;`
- `classfile CLASSNAME;` (adds `.class` to the name).
You can define the destination directory using these options:
- `-d`: Specifies the root directory for the output, following the class package structure.
- `-w`: Specifies the exact directory for the output file.
If neither option is used, JASM outputs to ``.
## Class Structure in JASM
A JASM file defines class or interface items as follows:
1. **Optional Package Declaration:**
```java
package package_name;
```
2. **Class or Interface Declaration**:
```java
[CLASS_MODIFIERS] class|interface CLASSNAME [extends SUPERCLASSNAME] { [CLASS_BODY] }
```
- The `CLASSNAME` determines the resulting file name.
- If `this_class` is defined in CLASS_BODY, the name does not affect the file's content but only its name.
If both `file FILENAME;` ( or `classfile CLASSNAME;`) and `class CLASSNAME { [CLASS_BODY] }` are present, the file(classfile) declaration takes priority.
### Example Command and Output
Here is an example of compiling a JASM file:
**Input Command:**
```shell
java -jar asmtools.jar jasm -d . FILE.jasm
```
**JASM File Content:**
```java
class FILENAME.data {
this_class CLASSNAME;
super_class SUPERCLASSNAME;
}
```
**Output:**
A binary file FILENAME.data is created. Decompiling this file (`java -jar asmtools.jar jdis FILENAME.data`) produces:
```java
super class CLASSNAME extends SUPERCLASSNAME version 45:0 {
}
```
---
## Description formats
| | |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| TERM1\|TERM2 | TERM1 or TERM2 (not both) |
| [ TERM ] | TERM is optional |
| TERM... | TERM repeated 1 or more times |
| [TERM...] | TERM repeated 0 or more times |
| "sequence of" | all the following terms are mandatory, in the order given. |
| "set of" | any of following terms, or none of them, may appear in any order. However, repetitions are not llowed. |
| "list of" | any of following terms, or none of them, may appear in any sequence. If more than one term appear, they are separated by commas (',') |
---
## Lexical Structure
# TODO
> ------------------------------------------------------------------------
>
>
> The source text file can be free form (newlines, tabs, and blank
> spaces are equivalent). Additionally, the source may contain standard
> Java and C++ comments.
>
> `STRING`, `NUMBER`, and `IDENT` are treated the same as in the Java
> Language Specification. One difference is that LETTERs include also
> \`/', \`<', \`>', \`(', and \`)' .
>
> _**`STRING`**_:
> `" [ STRING_CHARACTER... ] "`
>
> _**`NUMBER`**_:
> `DIGIT...`
>
> _**`IDENT`**_:
> `LETTER [ LETTER_OR_DIGIT ...]`
>
> _**`ACCESS`**_ (depends on the context): set of
> `abstract final interface native private protected public static super synchronized transient volatile deprecated synthetic bridge varargs`
>
> Not all access bits make sense for all declarations: for example, the
> "super" and "interface" access flags are applied to classes only.
>
> If an access bit is used improperly, the assembler prints a warning,
> but places the bit in the access set.
>
> Note that `deprecated` and `synthetic` keywords are not translated to
> access flags in the Java sense. For these jasm generates a
> corresponding `Deprecated` or `Synthetic` attributes instead of access
> bits. The `synthetic` access flag is used to mark compiler generated
> members not seen in the source (for example, a field reference to an
> anonymous outer class).
>
> _**`TAG`**_: one of
> `int float long double Asciz String class Field Method NameAndType InterfaceMethod MethodType MethodHandle InvokeDynamic Dynamic`
>
> Local names represent labels, rangePC-labels and local variables.
> Their scope is constrained by method parenthesis.
>
> _**`LOCAL_NAME`**_:
> `IDENT`
>
>
>
> _**`CONSTANT_INDEX`**_:
> `#NUMBER`
>
> Each CONSTANT\_INDEX represents a reference into the constant pool at
> the specified location.
------------------------------------------------------------------------
# General Class Structure
_**`INTERFACES`**_:list of
`CONSTANT_CELL(class|@interface|interface)`
_**`TOP_LEVEL_COMPONENT`**_: one of
`CONSTANT_DECLARATION FIELD_DECLARATION METHOD_DECLARATION INNER_CLASS_DECLARATIONS`
_**`CLASS`**_: sequence of
`ANNOTATIONS CLASS_ACCESS CONSTANT_CELL(class|@interface|interface) [extends CONSTANT_CELL(class)] [implements INTERFACES] [version INTEGER:INTEGER] { [TOP_LEVEL_COMPONENT...] }`
`CLASS_ACCESS``: list of`
`[public]``[final]``[super]``[interface]``[abstract]``[synthetic]``[annotation]``[enum]`
The `extends CONSTANT_CELL(class)` clause places the "super" element of
the class file. The `implements INTERFACES` clause places the table of
interfaces. Since the assembler does not distinguish interfaces and
ordinary classes (the only difference is one access bit), the table of
interfaces of an interface class must be declared with `implements`
keyword, and not `extends`, as in Java language.
**Note:**The last two rules allow `TOP_LEVEL_COMPONENT` to appear in any
order and number. For example, you can split constant pool table into
several parts, mixing constants and method declarations.
------------------------------------------------------------------------
# General Module Structure
_**`MODULE`**_: sequence of
`ANNOTATIONS [MODULE_FLAGS] moduleContent CONSTANT_CELL(moduleContent) [version INTEGER:INTEGER] {[TOP_LEVEL_MODULE_PROPERTIES...]}`
_**`TOP_LEVEL_MODULE_PROPERTIES`**_: one of
`MODULE_REQUIRES` `MODULE_EXPORTS` `MODULE_OPENS` `MODULE_USES`
`MODULE_PROVIDES`
`MODULE_FLAGS``:set of`
`[open]`
------------------------------------------------------------------------
# General Source File Structure
_**`PACKAGE_DECLARATION`**_:
`package IDENT;`
Package declaration can appear only once in source file.
_**`CLASS_FILE`**_: sequence of
`PACKAGE_DECLARATION CLASS...`
_**`MODULE_FILE`**_:
`MODULE...`
_**`SOURCE_FILE`**_:
`MODULE_FILE|CLASS_FILE`
------------------------------------------------------------------------
# The Constant Pool and Constant Elements
A `CONSTANT_CELL` refers to an element in the constant pool. It may
refer to the element either by its index or its value:
_**`CONSTANT_CELL`**_:
`CONSTANT_INDEX`
`TAGGED_CONSTANT_VALUE`
Generic rule for TAGGED\_CONSTANT\_VALUE is:
_**`TAGGED_CONSTANT_VALUE`**_:
`[TAG] CONSTANT_VALUE`
A TAG may be omitted when the context only allows one kind of a tag. For
example, the argument of an `anewarray` instruction should be a
`CONSTANT_CELL` which represents a class, so instead of
anewarray class java/lang/Object
one may write:
anewarray java/lang/Object
It is possible to write another tag, e.g.:
anewarray String java/lang/Object
However, the resulting program will be incorrect.
Another example of an implicit tag (eg. a context which implies tag) is
the header of a class declaration. You may write:
aClass {
}
which is equivalent to:
class aClass {
}
Below, the tag implied by context will be included in the rules, e.g.:
CONSTANT_VALUE(int).
The exact notation of `CONSTANT_VALUE` depends on the (explicit or
implicit) `TAG.`
_**`TAGGED_CONSTANT_VALUE`**_:
>
> _Note_
> When the JASM parser encounters an InvokeDynamic constant, it creates
> an entry in the _BootstrapMethods_ attribute (the _BootstrapMethods_
> attribute is produced if it has not already been created). The entry
> contains a reference to the _MethodHandle_ item in the constant pool,
> and, optionally, a sequence of references to additional static
> arguments (_ldc_-type constants) to the _bootstrap method_
INVOKESUBTAGs for MethodHandle and (const) InvokeDynamic are defined as
follows and can be presented as either an index or a tag:
_**`INVOKESUBTAG: [INVOKESUBTAG_INDEX]`**_
>
>
>
>
REF_GETFIELD
>
[1]
>
>
>
REF_GETSTATIC
>
[2]
>
>
>
REF_PUTFIELD
>
[3]
>
>
>
REF_PUTSTATIC
>
[4]
>
>
>
REF_INVOKEVIRTUAL
>
[5]
>
>
>
REF_INVOKESTATIC
>
[6]
>
>
>
REF_INVOKESPECIAL
>
[7]
>
>
>
REF_NEWINVOKESPECIAL
>
[8]
>
>
>
REF_INVOKEINTERFACE
>
[9]
>
>
>
Static arguments for an InvokeDynamic constant are defined as follows:
_**`INVOKEDYNAMIC_STATIC_ARGUMENTS`**_:
`INVOKEDYNAMIC_STATIC_ARG ',' ...`
_**`INVOKEDYNAMIC_STATIC_ARG`**_: (one of)
`INVOKEDYNAMIC_STATIC_ARG_CONSTANT_VALUE`
_**`INVOKEDYNAMIC_STATIC_ARG_CONSTANT_VALUE`**_:
>
>
>
>
int
>
INTEGER
>
>
>
long
>
[INTEGER|LONG]
>
>
>
float
>
[FLOAT|INTEGER]
>
>
>
double
>
[FLOAT|DOUBLE|INTEGER|LONG]
>
>
>
class
>
CONSTANT_NAME
>
>
>
String
>
CONSTANT_NAME
>
>
>
MethodHandle
>
INVOKESUBTAG:CONSTANT_FIELD
>
>
>
MethodType
>
CONSTANT_NAME
>
>
>
`INTEGER`, `LONG`, `FLOAT`, and `DOUBLE` correspond to `IntegerLiteral`
and `FloatingPointLiteral` as described in [The Java Language
Specification](https://docs.oracle.com/javase/specs/jls/se8/html/index.html).
If a double-word constant (`LONG` or `DOUBLE`) is represented with a
single-word value (`INTEGER` or `FLOAT`, respectively), single-word
value is simply promoted to double-word, as described in [The Java
Language
Specification](https://docs.oracle.com/javase/specs/jls/se8/html/index.html).
If floating-point constant (`FLOAT` or `DOUBLE`) is represented with an
integral value (`INTEGER` or `LONG`, respectively), the result depends
on whether the integral number is preceded with the keyword "bits". If
"bits" is not used, the result is a floating-point number closest in
value to the decimal number. If the keyword "bits" is used, the
floating-point constant takes bits of the integral value without
conversion.
Thus,
float 2;
means the same as
float 2.0f;
and the same as
float bits 0x40000000;
while
float bits 2;
actually means the same as
float bits 0x00000002;
and the same as
float 2.8026e-45f
_**`CONSTANT_NAME`**_:
`CONSTANT_INDEX`
`EXTERNAL_NAME`
_**`EXTERNAL_NAME`**_:
`IDENT STRING`
External names are names of class, method, field, or type, which stay in
resulting .class file, and may be represented both by `IDENT` or by
`STRING` (which is useful when name contains non-letter characters).
_**`NAME_AND_TYPE`**_:
`CONSTANT_INDEX`
`CONSTANT_NAME:CONSTANT_NAME`
In this second example, the first `CONSTANT_NAME` denotes the name of a
field and second denotes its type.
_**`CONSTANT_FIELD`**_:
`CONSTANT_INDEX`
`[CONSTANT_NAME.]NAME_AND_TYPE`
In this third example, `CONSTANT_NAME` denotes to the class of a field.
If `CONSTANT_NAME` is omitted, the current class is assumed.
------------------------------------------------------------------------
# Constant Declarations
Constant declarations are demonstrated in the examples below:
const #1=int 1234
, #2=String "a string"
, #3=Method get:I
;
_**`CONSTANT_DECLARATION`**_:
`const CONSTANT_DECLARATORS ;`
_**`CONSTANT_DECLARATORS`**_: list of
`CONSTANT_DECLARATOR`
_**`CONSTANT_DECLARATOR`**_:
`CONSTANT_INDEX = TAGGED_CONSTANT_VALUE`
------------------------------------------------------------------------
# Field Variables
_**`FIELD_DECLARATION`**_:
`ANNOTATIONS ``FIELD_ACCESS Field FIELD_DECLARATORS ;`
_**`FIELD_DECLARATORS`**_: list of
`FIELD_DECLARATOR`
_**`FIELD_DECLARATOR`**_:
`EXTERNAL_NAME:CONSTANT_NAME [:SIGNATURE] [ = TAGGED_CONSTANT_VALUE ]`
`FIELD_ACCESS``: list of`
`[public|private|protected]``[final]``[static]``[volatile]``[transient]``[synthetic]``[enum]`
Example:
public static Field
field1:I = int 1234,
field2:"Ljava/lang/String;",
field3:"Ljava/util/List;":"Ljava/util/List<+Ljava/lang/String;>"
;
Access bits (public and static) are applied both to field1 and field2.
The `EXTERNAL_NAME` denotes the name of the field, `CONSTANT_NAME`
denotes its type, `TAGGED_CONSTANT_VALUE` denotes initial value.
------------------------------------------------------------------------
# Method Declarations
_**`METHOD_DECLARATION`**_: sequence of
`ANNOTATIONS ``METHOD_ACCESS Method`
`EXTERNAL_NAME:CONSTANT_NAME`
`[THROWS]`
`STACK_SIZE`
`[LOCAL_VAR_SIZE]`
`{ INSTRUCTION_STATEMENT...`
`ANNOTATIONS }`
The `EXTERNAL_NAME` denotes the name of the method, `CONSTANT_NAME`
denotes its type.
`METHOD_ACCESS``: list of`
`[public|private|protected]``[static][final]``[synthetic]``[bridge]``[varargs]``[native][abstract]``[strict]``[synthetic]`
_**`THROWS`**_:
`throws EXCEPTIONS`
_**`EXCEPTIONS`**_: list of
`CONSTANT_CELL(class)`
The meaning of the `THROWS` clause is the same as in Java Language
Specification - it forms Exceptions attribute of a method. Jasm itself
does not use this attribute in any way.
_**`STACK_SIZE`**_:
`stack NUMBER`
The `NUMBER` denotes maximum operand stack size of the method.
_**`LOCAL_VAR_SIZE`**_:
`locals NUMBER`
The `NUMBER` denotes number of local variables of the method. If
omitted, it is calculated by assembler according to the signature of the
method and local variable declarations.
------------------------------------------------------------------------
# Instructions
>
>
> ## VM Instructions
>
> _**`INSTRUCTION_STATEMENT`**_:
> `[NUMBER] [LABEL:] INSTRUCTION|PSEUDO_INSTRUCTION ;`
>
> Jasm allows for a `NUMBER` (which is ignored) at the beginning of each
> line. This is allowed in order to remain consistent with the jdis
> disassembler. Jdis puts line numbers in disassembled code that may be
> reassembled using Jasm without any additional modifications.
>
> _**`INSTRUCTION`**_:
> `OPCODE [ARGUMENTS]`
>
> _**`ARGUMENTS`**_: list of
> `ARGUMENT`
>
> _**`ARGUMENT`**_:
> `NUMBER LABEL LOCAL_VARIABLE TRAP_IDENT CONSTANT_CELL SWITCHTABLE TYPE`
>
> _**`LABEL`**_:
> `NUMBER IDENT`
>
> _**`LOCAL_VARIABLE`**_:
> `NUMBER IDENT`
>
> _**`TRAP_IDENT`**_:
> `IDENT`
>
> _**`TYPE`**_:
> `NUMBER boolean byte char int float long double class`
>
> _**`SWITCHTABLE`**_:
> `{ [NUMBER:LABEL...] [default:LABEL] }`
>
> SWITCHTABLE example: Java\_text
>
> switch (x) {
> case 11:
> x=1;
> break;
> case 12:
> x=2;
> break;
> default:
> x=3;
> }
>
>
>
> will be coded in assembler as follows:
>
> tableswitch {
> 11: L24;
> 12: L29;
> default: L34
> }
> L24: iconst_1;
> istore_1;
> goto L36;
> L29: iconst_2 ;
> istore_1;
> goto L36;
> L34: iconst_3;
> istore_1;
> L36: ....
>
>
>
> OPCODE is any mnemocode from the instruction set. If mnemocode needs
> an ARGUMENT, it cannot be omitted. Moreover, the kind (and number) of
> the argument(s) must match the kind (and number) required by the
> mnemocode:
>
>
>
>
>
> ## InvokeDynamic Instructions
>
> _InvokeDynamic instructions_ are instructions that allow dynamic
> binding of methods to a call site. These instructions in JASM form are
> rather complex, and the JASM assembler does some of the necessary work
> to create a _BootstrapMethods_ attribute for entries of binding
> methods.
>
> > class Test
> > version 51:0
> > {
> > Method m:"()V"
> > stack 0 locals 1
> > {
> > invokedynamic InvokeDynamic REF_invokeSpecial:bsmName:"()V" // information about bootstrap method
> > :methName:"(I)I" // dynamic call-site name ("methName") plus the argument and return types of the call ("(I)I")
> > int 1, long 2l; // optional sequence of additional static arguments to the bootstrap method (ldc-type constants)
> > }
> > } // end Class Test
>
> This JASM code has an _invokedynamic_ instruction of the form:
> _**invokedynamic InvokeDynamic (CONSTANT\_CELL(INVOKEDYNAMIC))**_
> where the INVOKEDYNAMIC constant is represented as
> [specified](#invokedynamicconstant)
>
> (i.e. _invokedynamic InvokeDynamic INVOKESUBTAG : CONSTANT\_FIELD
> (bootstrapmethod signature) : NAME\_AND\_TYPE (CallSite) \[Arguments
> (Optional)\]_ ).
>
> The JASM assembler creates the appropriate constant entries and
> entries into the BootstrapMethods attribute in a resulting class file.
>
> You can also create InvokeDynamic constants and BootstrapMethods
> explicitly:
>
> > #22; //class Test3
> > version 51:0
> > {
> >
> > const #1 = InvokeDynamic 0:#11; // REF_invokeSpecial:Test3.bsmName:"()V":name:"(I)I" int 1, long 2l
> > const #2 = Asciz "Test3";
> > const #3 = long 2l;
> > const #5 = class #6; // java/lang/Object
> > const #6 = Asciz "java/lang/Object";
> > const #7 = Asciz "name";
> > const #8 = int 1;
> > const #9 = Asciz "SourceFile";
> > const #10 = Asciz "Test3.jasm";
> > const #11 = NameAndType #7:#21; // name:"(I)I"
> > const #12 = Asciz "()V";
> > const #13 = Method #22.#17; // Test3.bsmName:"()V"
> > const #14 = Asciz "Code";
> > const #15 = Asciz "m";
> > const #16 = Asciz "BootstrapMethods";
> > const #17 = NameAndType #20:#12; // bsmName:"()V"
> > const #18 = Asciz "LineNumberTable";
> > const #19 = MethodHandle 7:#13; // REF_invokeSpecial:Test3.bsmName:"()V"
> > const #20 = Asciz "bsmName";
> > const #21 = Asciz "(I)I";
> > const #22 = class #2; // Test3
> > const #23 = class #6; // java/lang/Object
> >
> >
> >
> > Method #15:#12
> > stack 0 locals 1
> > {
> > 0: invokedynamic InvokeDynamic #1; // InvokeDynamic REF_invokeSpecial:Test3.bsmName:"()V":name:"(I)I" int 1, long 2l;
> > }
> >
> > BootstrapMethod #19 #8 #3;
> >
> > } // end Class Test3
>
> In this example, `const #1 = InvokeDynamic 0:#11;` is the
> InvokeDynamic constant that refers to BootstrapMethod at index '0' in
> the BootstrapMethods Attribute (`BootstrapMethod #19 #8 #3;` which
> refers to the _MethodHandle_ at const \#19, plus 2 other static args
> (at const \#8 and const \#3).
## Pseudo Instructions
> Pseudo instructions are 'assembler directives', and not really
> instructions (in the VM sense) They typically come in two forms:
> Code-generating Pseudo-Instructions, and Attribute-Generating
> Pseudo-Instructions.
>
>
>
> ### Code-Generating Pseudo-Instructions
>
> The _bytecode_ directive instructs the assembler to put a collection
> of raw bytes into the code attribute of a methodK
>
>
> _**`bytecode NUMBERS`**_
> NUMBERS is list of NUMBERs (divided by COMMA).
> Insert bytes in place of the instruction. May have any number of
> numeric arguments, each of them to be converted into a byte and
> inserted in method's code.
>
>
>
> ### Attribute-Generating Pseudo-Instructions
>
> The rest of pseudo\_instructions do not produce any bytecodes, and are
> used to form tables: local variable table, exception table,
> Stack Maps, and Stack Map Frames. Line Number Tables can not be
> specified, but they are constructed by the assembler itself.
>
> > #### Local Variable Table Attribute Generation
> >
> > _**`var LOCAL_VARIABLE`**_
> > Starts local variable range
> >
> > _**`endvar LOCAL_VARIABLE`**_
> > Ends local variable range. LOCAL\_VARIABLE means name or index of
> > local variable table entry.
> >
> > Example:
> >
> > static void main (String[] args) {
> > Tester inst = new Tester();
> > inst.callSub();
> > }
> >
> > will be coded in assembler as follows:
> >
> > > > > static Method #8:#9 // main:"([Ljava/lang/String;)V"
> > > > > stack 2 locals 2
> > > > > {
> > > > > 4 var 0; // args:"[Ljava/lang/String;"
> > > > > 0: new #1; // class Tester;
> > > > > 3: dup;
> > > > > 4: invokespecial #2; // Method "":"()V";
> > > > > 7: astore_1;
> > > > > 6 var 1; // inst:"LTester;"
> > > > > 8: aload_1;
> > > > > 9: invokevirtual #3; // Method callSub:"()V";
> > > > > 7 12: return;
> > > > > endvar 0, 1;
> > > > >
> > > > > }
> >
> > #### Exception Table Attribute Generation
> >
> > To generate exception table, three pseudo-instructions are used.
> >
> > > _**`try TRAP_IDENT`**_
> > > Starts rangePC range
> > >
> > > _**`endtry TRAP_IDENT`**_
> > > Ends rangePC range
> > >
> > > _**`catch TRAP_IDENT CONSTANT_CELL(class)`**_
> > > Starts exception handler.
> >
> > `TRAP_IDENT` represents the name or number of an exception table
> > entry. `CONSTANT_CELL` in "catch" pseudo\_instruction means catch
> > type. Each exception table entry contains 4 values:start-pc, end-pc,
> > catch-pc, catch-type. In jasm, each entry is denoted with some
> > (local) identifier, as an example: `TRAP_IDENT`.
> >
> > To set start-pc, place "try TRAP\_IDENT" before the instruction with
> > the desirable program counter. Similarly, use "endtry TRAP\_IDENT"
> > for end-pc and "catch TRAP\_IDENT, catch-type" for catch-pc and
> > catch-type (which is usually a constant pool reference). Try,
> > endtry, and catch pseudoinstructions may be placed in any order. The
> > order of entries in exception table is significant (see JVM
> > specification). However, the only way to control this order is to
> > place catch-clauses in appropriate textual order: assembler adds an
> > entry in the exception table each time it encounters a catch-clause.
> >
> > Example:
> >
> > try {
> > try {
> > throw new Exception("EXC");
> > } catch (NullPointerException e){
> > throw e;
> > } catch (Exception e){
> > throw e;
> > }
> > } catch (Throwable e){
> > throw e;
> > }
> >
> > will be coded in assembler as follows:
> >
> > > try R1, R2; // single "try" or "endtry" can start several regions
> > > new class java/lang/Exception;
> > > dup;
> > > ldc String "EXC";
> > > invokespecial java/lang/Exception.:"(Ljava/lang/String;)V";
> > > athrow;
> > > endtry R1;
> > > catch R1 java/lang/NullPointerException; // only one "catch" per entry allowed
> > > astore_1;
> > > aload_1;
> > > athrow;
> > > catch R1 java/lang/Exception; // same region (R1) can appear in different catches
> > > astore_1;
> > > aload_1;
> > > athrow;
> > > endtry R2;
> > > catch R2 java/lang/Throwable;
> > > astore_1;
> > > aload_1;
> > > athrow;
> > >
> > >
> >
> > #### StackMap Table Attribute Generation
> >
> > Stack Maps are denoted by the pseudo-op opcode _stack\_map, and they
> > can be identified by three basic items:_
> >
> > _**`StackMapStatement =`**_``stack\_map
> > _**`(stackMap_Item_MapType |stackMap_Item_Object | stackMap_Item_NewObject)`**_``
> >
> > _**`stackMap_Item_MapType = (`_**bogus | int | float | double | long
> > | null | this | CP**_`)`**_``
> >
> > _**`stackMap_Item_Object = CONSTANT_CELL_CLASS`**_
> > _**`stackMap_Item_NewObject =`**_``at``_**`LABEL`**_``
> >
> > All stack\_map directives are collected by the assembler, and are
> > used to create a StackMap Table attribute.
> >
> > Example 1
> > (MapType):
> >
> > public Method "":"()V"
> > stack 1 locals 1
> > {
> > aload_0;
> > invokespecial Method java/lang/Object."":"()V";
> > return;
> > stack_frame_type full;
> > stack_map bogus;
> > ...
> > }
> >
> >
> > Example 2 (Object):
> >
> > public Method
> > "<init>":"()V"
> > stack 2 locals 1
> > {
> > ...
> > ***stack\_map class java/lang/Object;***
> > nop;
> > return;
> > }
> >
> > Example 3 (NewObject):
> >
> > public Method
> > "<init>":"()V"
> > stack 2 locals 1
> > {
> > ...
> > ***stack\_map at L5;***
> > nop;
> > return;
> > }
> >
> >
> >
> > #### StackFrameType Table Attribute Generation
> >
> > StackFrameTypes are similar assembler directives as StackMap. These
> > directives can appear anywhere in the code, and the assembler will
> > collect them to produce a StackFrameType attribute.
> >
> > _**`StackFrameStatement =`**_``stack\_frame\_type``_**`frame_type`**_
> >
> > _**`frame_type = (`**_ same | stack1 | stack1\_ex | chop1 | chop2 |
> > chop3 | same\_ex | append | full _**`)`**_
> >
> > Example 1 (full _stack frame type_):
> >
> > public Method "":"()V"
> > stack 1 locals 1
> > {
> > aload_0;
> > invokespecial Method java/lang/Object."":"()V";
> > return;
> > stack_frame_type full;
> > stack_map bogus;
> > ...
> > }
> >
> > Example 2 (append, chop2, and same _stack frame types_):
> >
> > public Method foo:"(Z)V"
> > stack 2 locals 5
> > {
> > ...
> > iload_2;
> > iconst_2;
> > if_icmpge L30;
> > L27: stack_frame_type append;
> > locals_map int, int;
> > iconst_2;
> > istore 4;
> > L30: stack_frame_type chop2;
> > goto L9;
> > L33: stack_frame_type same;
> > getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
> > ldc String "Chop2 attribute test";
> > invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
> > return;
> > ...
> > }
> >
> > #### LocalsMap Table
> >
> > Locals Maps are typically associated with a _stack\_frame\_type_,
> > and are accumulated per stack frame. They typically follow a
> > _stack\_frame\_type_ directive.
> >
> > _**`LocalsMapStatement =`**_``locals\_map``_**`locals_type (, locals_type )*`**_
> >
> > _**`locals_type = stackMap_Item_MapType | CONSTANT_CELL_CLASS`**_``
> >
> > Example (a _locals map_ specifying 2 ints):
> >
> > public Method foo:"(Z)V"
> > stack 2 locals 5
> > {
> > ...
> > iload_2;
> > iconst_2;
> > if_icmpge L30;
> > L27: stack_frame_type append;
> > locals_map int, int;
> > iconst_2;
> > istore 4;
> > L30: stack_frame_type chop2;
> > goto L9;
> > L33: stack_frame_type same;
> > getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
> > ldc String "Chop2 attribute test";
> > invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
> > return;
> > ...
> > }
------------------------------------------------------------------------
# Inner Class Declarations
_**`INNER_CLASS_DECLARATIONS`**_: list of
`INNER_CLASS_DECLARATION`
_**`INNER_CLASS_DECLARATION`**_:
`INNER_CLASS_ACCESS`**`InnerClass`**`[INNER_CLASS_NAME`**`=`**`]? INNER_CLASS_INFO [`**`of`**`OUTER_CLASS_INFO]? ;`
_**`INNER_CLASS_NAME`**_:
`IDENT | CPX_name`
_**`INNER_CLASS_INFO`**_:
`CONSTANT_CELL(class)`
_**`OUTER_CLASS_INFO`**_:
`CONSTANT_CELL(class)`
_**`INNER_CLASS_ACCESS`**_`: list of`
`[public|protected|private][static][final][interface][abstract][synthetic][annotation][enum]`
Example:
InnerClass InCl=class test$InCl of class test;
------------------------------------------------------------------------
# Annotation Declarations
## Member Annotations
Member annotations are a subset of the basic annotations support
provided in JDK 5.0 (1.5). These are annotations that ornament Packages,
Classes, and Members either visibly (accessible at runtime) or invisibly
(not accessible at runtime). In JASM, visible annotations are denoted by
the token **@**, while invisible annotations are denoted by the token
**@-**.
#### Synopsis
_**`ANNOTATIONS`**_:
`[ANNOTATION_DECLARATION]+`;
_**`ANNOTATION_DECLARATION`**_:
**`@+`**`|`**`@-`**`ANNOTATION_NAME [ANNOTATION_VALUE_DECLARATIONS]`
The '**@+**' token identifies a Runtime Visible Annotation, where the
'**@-' token identifies a Runtime Invisible Annotation.**
_**`ANNOTATION_NAME`**_:
`IDENT`
_**`ANNOTATION_VALUE_DECLARATIONS`**_: list of (comma separated)
`ANNOTATION_VALUE_DECLARATION`
_**`ANNOTATION_VALUE_DECLARATION`**_:
`[ANNOTATION_VALUE_IDENT=] [ANNOTATION_VALUE]`
_**`ANNOTATION_VALUE_IDENT`**_:
`IDENT`
_**`ANNOTATION_VALUE`**_:
`ANNOTATION_VALUE_PRIMITIVE | Array of ANNOTATION_VALUE_PRIMITIVE`
_**`ANNOTATION_VALUE_PRIMITIVE`**_:
`PRIMITIVE_TYPE | STRING | CLASS | ENUM | ANNOTATION_DECLARATION`
_**`CLASS`**_:
**`class`**`CONSTANT_CELL(class)`
_**`ENUM`**_:
**`enum CONSTANT_CELL(class) CONSTANT_CELL(string) (where string is Enum type name)`**
_**`PRIMITIVE_TYPE`**_:
`BOOLEAN | BYTE | CHAR | SHORT | INTEGER | LONG | FLOAT | DOUBLE`
_**Note**_
Types (Boolean, Byte, Char, and Short) are normalized into Integer's
within the constant pool.
Annotation values with these types may be identified with a keyword
in front of an integer value.
eg. **boolean** true (or: boolean 1)
**byte** 20
**char** 97
**short** 2130
Other primitive types are parsed according to normal prefix and
suffix conventions
(eg. Double = xxx.x**d**, Float = xxx.x**f**, Long = xxx**L**).
Strings are identified and delimited by '"' (quotation marks).
Keywords '**class**' and '**enum**' identify those annotation types
explicitly. Values within classes and enums may
either be identifiers (strings) or Constant Pool IDs.
Annotations specified as the value of an Annotation field are
identified by the JASM annotation keywords '**@+**' and '**@-**'.
Arrays are delimited by '{' and '}' marks, with individual elements
delimited by ',' (comma).
#### ExamplesExample 1 (Class Annotation, Visible)
@+ClassPreamble {
author = "John Doe",
date = "3/17/2002",
currentRevision = 6,
lastModified = "4/12/2004",
lastModifiedBy = "Jane Doe",
reviewers = {
"Alice",
"Bob",
"Cindy"}
}
super public class MyClass
version 50:0
{
...
Example 2 (Field Annotation,
Invisible)
@-FieldPreamble {
author = "Mustafa",
date = "3/17/2009",
currentRevision = 4
}
Field foo:I;
...
Example 3 (Field Annotation,
All subtypes)
@+FieldPreamble {
boolAnnot = boolean 1, // Boolean
charBear = char 97, // Char
sharkByte = byte 17, // Byte
shortCircuit = short 4386, // Short
integerHead = 42, // Int
longJohnSilver = 55l, // Long
floatBoat = 1.0f, // Float
doubleDip = 10.0d, // Double
stringBeans = "foo", // String
severity = enum FieldPreamble$Severity IMPORTANT, // Enum
classAnnot = class FieldPreamble$FooBall, // Class
tm = @+Trademark { description = "embedded", owner = "ktl"} // Annotation
}
Field foo:I;
...
Example 4 (Module Annotation, Visible)
@+java/lang/Deprecated {
since = "9",
forRemoval = boolean true
}
moduleContent my.moduleContent
version 53:0
{
...
Note:
JASM does not enforce the annotation value declarations like a compiler
would. It only checks to see that an annotation structure is
well-formed.
## Type Annotations
Member annotations are a subset of the basic annotations support
provided in JDK 7.0 (1.7). These are annotations that ornament Packages,
Classes, and Members either visibly (accessible at runtime) or invisibly
(not accessible at runtime). In JASM, visible annotations are denoted by
the token **@T+**, while invisible annotations are denoted by the token
**@T-**.
#### Synopsis
_**`TYPE_ANNOTATION_DECLARATION`**_:
**`@T+`**`|`**`@T-`**`ANNOTATION_NAME [TYPE_ANNOTATION_VALUE_DECLARATIONS]`
_**`TYPE_ANNOTATION_VALUE_DECLARATIONS`**_: list of (comma separated)
`TYPE_ANNOTATION_VALUE_DECLARATION`
_**`TYPE_ANNOTATION_VALUE_DECLARATION`**_:
**`{`**``**`{`**`ANNOTATION_VALUE_DECLARATION`**`+`**``**`}`**` TARGET PATH`` `**`}`**
_**`TARGET`**_:
**`{`**` TARGET_TYPE TARGET_INFO `**`}`**
****
_**`TARGET_TYPE`**_`:`
``
TARGET_TYPE:
TARGET_INFO_TYPE:
CLASS_TYPE_PARAMETER
TYPEPARAM
METHOD_TYPE_PARAMETER
TYPEPARAM
CLASS_EXTENDS
SUPERTYPE
CLASS_TYPE_PARAMETER_BOUND
TYPEPARAM_BOUND
METHOD_TYPE_PARAMETER_BOUND
TYPEPARAM_BOUND
FIELD
EMPTY
METHOD_RETURN
EMPTY|
METHOD_RECEIVER
EMPTY
METHOD_FORMAL_PARAMETER
METHODPARAM
THROWS
EXCEPTION
LOCAL_VARIABLE
LOCALVAR
RESOURCE_VARIABLE
LOCALVAR
EXCEPTION_PARAM
CATCH
INSTANCEOF
OFFSET
NEW
OFFSET
CONSTRUCTOR_REFERE CE_RECEIVER
OFFSET
METHOD_REFERENCE_RECEIVER
OFFSET
CAST
TYPEARG
CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
TYPEARG
METHOD_INVOCATION_TYPE_ARGUMENT
TYPEARG
CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
TYPEARG
METHOD_REFERENCE_TYPE_ARGUMENT
TYPEARG
_**`TARGET_INFO`**_`_TYPE``:`
``
`TYPEPARAM | SUPERTYPE | TYPEPARAM_BOUND | EMPTY | METHODPARAM | EXCEPTION | LOCALVAR | CATCH |`` OFFSET | TYPEARG`
****
**`TYPEPARAM`**`:`
`paramIndex(`_`INTEGER`_`)`` `
**`SUPERTYPE`**`:`
`typeIndex(`_`INTEGER`_`)``typeIndex(``INTEGER``)`` `
**`TYPEPARAM_BOUND`**`:`
`paramIndex(`_`INTEGER`_`) ``boundIndex(`_`INTEGER`_`)`` `
**`EMPTY`**`:`
``
**`METHODPARAM`**`:`
`index(`
`paramIndex(`_`INTEGER`_`)`
**`EXCEPTION`**`:`
`typeIndex(`_`INTEGER`_`)`_``_``
****
_**`LOCALVAR`**_`:`
`{```**`LVENTRY }``+numEntries`**``
``
_**`LVENTRY`**_`:`
`startpc(`_`INTEGER)`_`length``(`_`INTEGER)`_`index(`_`INTEGER)`_``
**`CATCH`**`:`
`catch(`_`INTEGER)`_
``
_**`OFFSET`**_`:`
``
`offset(`_`INTEGER)`_
``
**`TYPEARG`**`:`
`offset(`_`INTEGER`_`) ``typeIndex(`_`INTEGER`_`)`` `
_**`PATH`**_`: list of (space separated)`
``
**`{`**_```PATH_ENTRY`_**`+`**``**`}`**
_**`PATH_ENTRY`**_`:`
``
`{``PATH_KIND PATH_INDEX }`
_**`PATH_KIND`**_`:`
``
`ARRAY | INNER_TYPE | WILDCARD | TYPE_ARGUMENT`
**`PATH_INDEX`**`:`
_`INTEGER`_``
****
****
## Parameter Names and Parameter Annotations
Parameter annotations are another subset of the basic annotations
support provided in JDK 5.0 (1.5). These are annotations that ornament
Parameters to methods either visibly (accessible at runtime) or
invisibly (not accessible at runtime). In JASM, visible parameter
annotations are denoted by the token **@+**, while invisible parameter
annotations are denoted by the token **@-**.
Parameter names come from an attribute introduced in JDK 8.0 (1.8).
These are fixed parameter names that are used to ornament parameters on
methods. In Jasm, parameter names are identified by the token \#
followed by { } braclets
#### Synopsis
_**`METHOD DECLARATION`**_:
`MODIFIERS Method METHOD_NAME:"METHOD_SIGNATURE" [STACK_DECL] [LOCALS_DECL] [PARAMETERS_DECL] {[CODE]}`
_**`PARAMETERS_DECL`**_:
`[PARAMETER_DECL]``N``(where N < number of params in method, each N is a unique param number)`
_**`PARAMETER_DECL`**_:
`PARAM_NUM : [PARAM_NAME_DECL] [ANNOTATION_DECLARATIONS]`
_**`PARAM_NAME_DECL`**_:
`#{ name PARAM_ACCESS}`
_**`PARAM_ACCESS`**_`: list of`
`[final][synthetic][mandated]`
#### Examples
Example 1 (Parameter Annotation)
_**Java Code**_
public class MyClass2 {
...
public int doSomething(
@VisParamPreamble ( author = "gummy" ) @InVisParamPreamble ( author = "bears" ) int barber,
boolean of,
@VisParamPreamble ( author = "sour" ) @InVisParamPreamble ( author = "worms" ) int seville,
@InVisParamPreamble1 ( reviewers = {"Dilbert", "Garfield"} ) boolean pastrami) {
...
}
...
}
_**JASM Code**_
Note: The first two
parameters are named ('P0'- 'P3'). Since this is a compiler controlled
option, there is no way to specify parameter naming in Java source.
super public class MyClass2
version 50:0
{
...
public Method doSomething:"(IZIZ)I"
stack 2 locals 5
0: #{P0 mandated} @+VisParamPreamble { author = "gummy" } @-InVisParamPreamble { author = "bears" }
1: #{P1 final synthetic mandated}
2: #{P2 mandated} @+VisParamPreamble { author = "sour" } @-InVisParamPreamble { author = "worms" }
3: #{P3 mandated} @-InVisParamPreamble1 { reviewers = { "Dilbert", "Garfield"} }
{
...
}
} // end Class MyClass2
## Default Annotations
Default annotations are another subset of the basic annotations
support provided in JDK 5.0 (1.5). These are annotations that ornament
Annotations either visibly (accessible at runtime) or invisibly (not
accessible at runtime). Default annotations specify a default value for
a given annotation field.
#### Synopsis
_**`ANNOTATION INTERFACE DECLARATION`**_:
`@interface ANNOTATION_NAME { ANNOTATION_FIELD_DECL``+``}`
_**`ANNOTATION_FIELD_DECL`**_:
`ANNOT_FIELD_TYPE ANNOTATION_NAME [ANNOTATION_DEFAULT_VALUE_DECL];`
_**`ANNOTATION_DEFAULT_VALUE_DECL`**_:
`default ANNOTATION_VALUE (where value must be of the type ANNOT_FIELD_TYPE)`
#### ExamplesExample 1 (Default Annotation)
_**Java Code**_
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@interface Meth2Preamble {
String author() default "John Steinbeck";
}
_**JASM Code**_
interface Meth2Preamble
implements java/lang/annotation/Annotation
version 50:0
{
public abstract Method author:"()Ljava/lang/String;" default { "John Steinbeck" } ;
} // end Class Meth2Preamble
------------------------------------------------------------------------
# Module properties
## Requires
_**`MODULE_REQUIRES`**_: sequence of
requires `REQUIRES_FLAGS` `CONSTANT_CELL(moduleContent)`;
_**`REQUIRES_FLAGS`**_: set of
\[`transitive`\] \[`static`\]
Example:
requires transitive static foo.bar;
## Exports
_**`MODULE_EXPORTS`**_: sequence of
exports `CONSTANT_CELL(package)` \[to `EXPORT_TO_MODULES`\];
_**`EXPORT_TO_MODULES`**_: list of
`CONSTANT_CELL(moduleContent)`
Example:
exports com/foo/bar to
foo2.bar2,
foo3.bar3;
exports org/foo/bar;
## Opens
_**`MODULE_OPENS`**_: sequence of
opens `CONSTANT_CELL(package)` \[to `OPENS_TO_MODULES`\];
_**`OPENS_TO_MODULES`**_: list of
`CONSTANT_CELL(moduleContent)`
Example:
opens com/foo/bar to
foo2.bar2,
foo3.bar3;
opens org/foo/bar;
## Uses
_**`MODULE_USES`**_: sequence of
uses `CONSTANT_CELL(class)`;
Example:
uses com/foo/bar;
## Provides
_**`MODULE_PROVIDES`**_: sequence of
provides `CONSTANT_CELL(class)` \[with `MODULE_PROVIDES_WITH_CLASSES`\];
_**`MODULE_PROVIDES_WITH_CLASSES`**_: list of
`CONSTANT_CELL(class)`
Example:
provides com/foo/bar with
foo2.bar2,
foo3.bar3;
provides com/foo/bar;
------------------------------------------------------------------------
# PicoJava Instructions
These instructions takes 2 bytes: prefix (254 for non-privileged variant
and 255 for privileged) and the opcode itself. These instructions can be
coded in assembler in 2 ways: as single mnemocode identical to the
description or using "priv" and "nonpriv" instructions followed with an
integer representing the opcode.
* This class provides methods for removing comments from strings,
* converting UTF-8 strings to printable formats, and handling character
* encoding in a way that is suitable for assembly tools.
*/
public class StringUtils {
public static final char[] hexTable = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
/**
* Removes Java comments from String
* Spaces ahead of comments will be removed; alternatively, if no spaces precede the comment,
* the space after it will be deleted.
*
* @param str string that contains comments
* @return string without comments
*/
public static String removeCommentFrom(String str) {
// firstly delete // comment if exists
int idx = str.indexOf("//");
if (idx != -1) {
str = str.substring(0, idx--);
if (str.charAt(idx) == ' ') {
str = str.substring(0, idx);
}
}
// remove /* some comment */ comments
String[] list = str.split("\\/\\*.*?\\*\\/");
if (list.length > 1) {
// comments found
str = "";
for (int i = 0; i < list.length; i++) {
idx = list[i].length() - 1;
if (list[i].charAt(idx) == ' ') {
str += list[i].substring(0, idx);
} else {
str += list[i];
idx = i + 1;
if (idx < list.length && list[idx].charAt(0) == ' ') {
list[idx] = list[idx].substring(1);
}
}
}
}
return str;
}
/**
* Converts CONSTANT_Utf8_info string to a printable string for jdis/jdec.
*
* @param utf8 UTF8 string taken from within ConstantPool of a class file
* @param enclosingString strings to enclose output string
* @return output string for jcod/jasm
*/
public static String Utf8ToString(String utf8, String... enclosingString) {
final String leftBracket = enclosingString.length > 0 ? enclosingString[0] : "";
final String rightBracket = enclosingString.length > 1 ? enclosingString[1] : leftBracket;
StringBuilder sb = new StringBuilder(leftBracket);
for (int k = 0; k < utf8.length(); k++) {
sb.append(charToUtf8String(utf8.charAt(k)));
}
return sb.append(rightBracket).toString();
}
/**
* Converts CONSTANT_Utf8_info string to a printable list of strings
* @param utf8 UTF8 string taken from within ConstantPool of a class file
* @param strLength the maximum length of each string in the resulting list
* @return list of strings for jcod/jasm
*/
public static List Utf8ToStringList(String utf8, int strLength) {
List list = new ArrayList<>();
String s = "";
for (int k = 0; k < utf8.length(); k++) {
if (s.length() >= strLength) {
list.add(s);
s = "";
}
s += charToUtf8String(utf8.charAt(k));
}
if (!s.isEmpty()) {
list.add(s);
}
return list;
}
/**
* Converts a character to its UTF-8 string representation.
*
* Control characters and special characters are escaped using the appropriate escape sequences.
* Other characters are returned as is.
*
* @param c the character to convert
* @return the UTF-8 string representation of the character
*/
public static String charToUtf8String(char c) {
return switch (c) {
case '\t' -> "\\".concat("t");
case '\n' -> "\\".concat("n");
case '\r' -> "\\".concat("r");
case '\b' -> "\\".concat("b");
case '\f' -> "\\".concat("f");
case '\"' -> "\\".concat("\"");
case '\'' -> "\\".concat("\'");
case '\\' -> "\\".concat("\\");
default -> Character.isISOControl(c) ? String.format("\\u%04x", (int) c) : Character.toString(c);
};
}
/**
* Checks that ch is in the list
*
* @param i char for testing
* @param list of chars
* @return true if char ch found in the list
*/
public static boolean isOneOf(int i, char... list) {
char ch = (char) i;
for (char c : list) {
if (c == ch)
return true;
}
return false;
}
/**
* Reads the set of bytes if all bytes are printable then they will be printed
* as the string "String"; otherwise the byte array 0x0F 0xB6 0x00 0x11;
* The result is the list of lines for printing.
*
* @param in input stream to get bytes for printing
* @param length number of bytes
* @param CHARS_IN_LINE max chars in line prepared for printing
* @return list of lines for printing
* @throws IOException exception might happen while reading DataInputStream
*/
public static List readUtf8String(DataInputStream in, int length, int CHARS_IN_LINE) throws IOException {
final int BYTES_IN_LINE = CHARS_IN_LINE / 6 + 1;
final List list = new ArrayList<>();
List byteLines = new ArrayList() {{
add(new StringBuilder());
}};
StringBuilder sb = byteLines.get(0);
byte[] buffer;
String utfString = null;
int count = 0;
try {
buffer = new byte[length + 2];
buffer[0] = (byte) (length >> 8);
buffer[1] = (byte) length;
for (int i = 0; i < length; i++) {
byte b = in.readByte();
buffer[i + 2] = b;
count++;
sb.append("0x").append(hexTable[(b >> 4) & 0xF]).append(hexTable[b & 0xF]);
if (i % BYTES_IN_LINE == BYTES_IN_LINE - 1) {
byteLines.add(sb = new StringBuilder());
} else if (i + 1 != length) {
sb.append(" ");
}
}
if (count > 0) {
try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer))) {
utfString = DataInputStream.readUTF(dis);
} catch (UTFDataFormatException utfDataFormatException) {
byteLines.add(0, new StringBuilder(format("// == %s ==", sharedI18n.getString("main.error.wrong.utf8"))));
} catch (IOException ignored) {
/*ignored*/
}
}
} catch (NegativeArraySizeException negativeArraySizeException) {
throw new IOException("Requested array size exceeds VM limit", negativeArraySizeException);
} finally {
if (count > 0) {
List utf8Lines = getPrintable(utfString, CHARS_IN_LINE);
if (utf8Lines != null) {
utf8Lines.stream().
forEach(s -> list.add(s.startsWith("// ==") ? s : format("\"%s\";", s)));
} else {
byteLines.stream().map(s -> s.toString()).
forEach(s -> list.add(s.startsWith("// ==") ? s : format("%s;", s)));
}
}
}
return list;
}
/**
* @param buffer array of bytes
* @return null if buffer contains at least one of non-printable bytes
* otherwise the list of strings encoded in the buffer
*/
public static List getPrintable(byte[] buffer, final int CHARS_IN_LINE) {
List list = null;
try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buffer))) {
String str = dis.readUTF();
list = getPrintable(str, CHARS_IN_LINE);
} catch (IOException e) {/*ignore*/}
return list;
}
/**
* @param rawString String
* @return null if buffer contains at least one of non-printable bytes
* otherwise the list of strings split by CHARS_IN_LINE
*/
public static List getPrintable(String rawString, final int CHARS_IN_LINE) {
List list = null;
if (rawString != null) {
String cleanedString = removeNonPrintableAscii(rawString);
if (cleanedString != null && !cleanedString.isEmpty() && !cleanedString.chars().anyMatch(c -> !isPrintableChar((char) c))) {
list = Utf8ToStringList(rawString, CHARS_IN_LINE);
}
}
return list;
}
/**
* Removes non-printable ASCII characters from the given input string.
*
* Non-printable ASCII characters are those with ASCII values outside the range of 32 (space) to 126 (tilde).
*
* @param input the input string to be processed
* @return a new string with non-printable ASCII characters removed, or null if the input is null
*/
public static String removeNonPrintableAscii(String input) {
if (input == null) return null;
StringBuilder result = new StringBuilder();
for (char c : input.toCharArray()) {
if (c >= 32 && c <= 126) {
result.append(c);
}
}
return result.toString();
}
/**
* Converts a list of strings to a formatted string representation.
* The output is enclosed in parentheses and elements are separated by commas.
*
* @param list the list of strings to convert
* @return a formatted string representation of the list
*/
public static String ListToString(List list) {
return ListToString(list, "(,)");
}
/**
* Converts a list of strings to a formatted string representation.
* The output is enclosed in square brackets and elements are separated by a specified delimiter.
*
* @param list the list of strings to convert
* @param separators a string containing the prefix, delimiter, and postfix characters
* (e.g., "[,]"), where:
* - first character is the prefix,
* - second character is the delimiter,
* - third character is the postfix.
* @return a formatted string representation of the list
*/
public static String ListToString(List list, String separators) {
int l = separators.length();
String prefix = separators != null && l > 0 ? separators.substring(0, 1) : "[";
String delim = separators != null && l > 1 ? separators.substring(1, 2) : ",";
String postfix = separators != null && l > 2 ? separators.substring(2, 3) : "]";
return prefix.concat(" ") + String.join(delim.concat(" "), list) + " ".concat(postfix);
}
/**
* Converts an array of integers to a hex string representation.
* Each integer is converted to its hexadecimal format and joined with commas.
*
* @param array the array of integers to convert
* @return a string representation of the array in hexadecimal format
*/
public static String mapToHexString(int[] array) {
return format("{%s}",
Arrays.stream(array).mapToObj(HexUtils::toHex).collect(Collectors.joining(", ")));
}
public static String repeat(String str, int count) {
return count <= 0 ? "" : new String(new char[count]).replace("\0", str);
}
/**
* Checks if the character is printable.
* A character is considered printable if it is not a control character,
* is not undefined, and belongs to a valid Unicode block that is not SPECIALS.
*
* @param c the character to check
* @return true if the character is printable, false otherwise
*/
public static boolean isPrintableChar(char c) {
Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
return (!Character.isISOControl(c)) &&
c != KeyEvent.CHAR_UNDEFINED &&
block != null &&
block != Character.UnicodeBlock.SPECIALS;
}
public static BiFunction, Boolean> endWith = (str, list) -> {
for (String suffix : list) {
if (str.endsWith(suffix)) {
return true;
}
}
return false;
};
public static BiFunction, Boolean> contains = (str, list) -> {
for (String substr : list) {
if (str.contains(substr)) {
return true;
}
}
return false;
};
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/asmutils/Triplet.java 0000664 0000000 0000000 00000002622 15143236361 0026413 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.asmutils;
// Helper class
public class Triplet extends Pair {
public final T third;
public Triplet(F first, S second, T third) {
super(first, second);
this.third = third;
}
@Override
public String toString() {
return "Triplet{ " + first + ", " + second + ", " + third + " }";
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/ 0000775 0000000 0000000 00000000000 15143236361 0023552 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/Compiler.java 0000664 0000000 0000000 00000003245 15143236361 0026173 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import static org.openjdk.asmtools.common.Environment.OK;
public abstract class Compiler> extends Tool {
protected Compiler(ToolOutput toolOutput, DualStreamToolOutput outerLog) {
super(toolOutput, outerLog);
}
public synchronized boolean compile(String... argv) {
parseArgs(argv);
return this.compile() == OK;
}
// Run a compiler when args already parsed
public abstract int compile();
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/CompilerConstants.java 0000664 0000000 0000000 00000003227 15143236361 0030070 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
/**
* This interface defines constant that are used throughout the compiler. It inherits from
* RuntimeConstants, which is an autogenerated class that contains constants defined in
* the interpreter.
*/
public interface CompilerConstants {
// End of input
int EOF = -1;
// Jasm: Number of bits used in file offsets
int OFFSET_BITS = 32;
//Jcoder: The increment for each character.
int OFFSET_INC = 1;
// BACKSLASH is a special code indicating a pushback of a backslash that
// definitely isn't the start of a unicode sequence.
int BACKSLASH = -2;
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/CompilerLogger.java 0000664 0000000 0000000 00000024371 15143236361 0027336 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.asmutils.Pair;
import org.openjdk.asmtools.common.inputs.ToolInput;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import java.io.IOException;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher;
import static java.lang.Math.min;
import static java.lang.String.format;
import static org.openjdk.asmtools.asmutils.StringUtils.repeat;
import static org.openjdk.asmtools.common.CompilerConstants.OFFSET_BITS;
import static org.openjdk.asmtools.common.EMessageKind.ERROR;
import static org.openjdk.asmtools.common.EMessageKind.WARNING;
import static org.openjdk.asmtools.common.Environment.OK;
import static org.openjdk.asmtools.common.structure.CFVersion.DEFAULT_MAJOR_VERSION;
import static org.openjdk.asmtools.common.structure.CFVersion.DEFAULT_MINOR_VERSION;
// error,warning and info message is general and attached to a position of a scanned file.
public class CompilerLogger extends ToolLogger implements ILogger {
// Message Container
private final Map> container = new HashMap<>();
private final List fileContent = new ArrayList<>();
/**
* @param programName the tool name
* @param cls the environment class of the tool for which to obtain the resource bundle
* @param outerLog the logger stream
*/
public CompilerLogger(String programName, Class> cls, DualStreamToolOutput outerLog) {
super(programName, cls, outerLog);
}
@Override
public void warning(long where, String id, Object... args) {
Message message = getResourceString(WARNING, id, args);
if (message.notFound()) {
if (EMessageKind.isFromResourceBundle(id)) {
insert(NOWHERE, new Message(ERROR, "(I18NResourceBundle) The warning message '%s' not found", id));
} else {
insert(where, new Message((strictWarnings) ? ERROR : WARNING, args.length == 0 ? id : format(id, args)));
}
} else {
insert(where, strictWarnings ? new Message(ERROR, message.text()) : message);
}
}
@Override
public void error(long where, String id, Object... args) {
Message message = getResourceString(ERROR, id, args);
if (message.notFound()) {
if (EMessageKind.isFromResourceBundle(id)) {
insert(NOWHERE, new Message(ERROR, "(I18NResourceBundle) The error message '%s' not found", id));
} else {
insert(where, new Message(ERROR, args.length == 0 ? id : format(id, args)));
}
} else {
insert(where, message);
}
}
@Override
public String getInfo(String id, Object... args) {
String message = getResourceString(id, args);
if (message == null) {
if (EMessageKind.isFromResourceBundle(id)) {
printErrorLn("(I18NResourceBundle) The info message '%s' not found", id);
} else {
println(id, args);
}
}
return message;
}
@Override
public void usage(List usageIDs) {
usage(usageIDs, id -> id.equals("info.opt.cv") ?
getInfo(id, DEFAULT_MAJOR_VERSION, DEFAULT_MINOR_VERSION) :
getInfo(id));
}
@Override
public void usage(List usageIDs, Function func) {
for (String id : usageIDs) {
String s = func.apply(id);
if (s != null) {
Matcher m = usagePattern.matcher(s);
if (m.find()) {
println(format(" %-35s %s", m.group(1).trim(), m.group(2).trim()));
} else {
println(s);
}
}
}
}
@Override
public void setInputFileName(ToolInput inputFileName) throws IOException {
super.setInputFileName(inputFileName);
fileContent.clear();
fileContent.addAll(inputFileName.readAllLines());
}
/**
* Gets a pair of line number and line position for the pointer where A position consists of: ((linenr >> OFFSETBITS) | offset)
* this means that both the line number and the exact offset into the file are encoded in each position value.
*
* @param where absolute position in file = (linepos << OFFSETBITS) | bytepos;
* @return the pair: [line number, line offset]
*/
Pair filePosition(long where) {
if (where == NOWHERE || fileContent.isEmpty()) {
return null;
} else {
long lineNumber = lineNumber(where);
return new Pair<>(lineNumber, lineOffset(lineNumber, where));
}
}
public long lineNumber(long where) {
return where >> OFFSET_BITS;
}
public long lineOffset(long lineNumber, long where) {
long absPos = where & ((1L << OFFSET_BITS) - 1);
return absPos - (fileContent.subList(0, (int) lineNumber - 1).
stream().mapToInt(String::length).sum() + lineNumber - 1);
}
public long getCount(EMessageKind kind) {
return noMessages() ? 0 : container.values().stream().
flatMap(Collection::stream).filter(m -> m.kind() == kind).count();
}
public boolean noMessages() {
return container.isEmpty();
}
/**
* @param printTotals whether to print the total line: N warning(s), K error(s)
* @return 0 if there are no errors otherwise a number of errors
*/
public synchronized int flush(boolean printTotals) {
if (noMessages()) return OK;
int nErrors = 0, nWarnings = 0;
List>> list = new ArrayList<>(container.entrySet());
list.sort(Map.Entry.comparingByKey());
ToolOutput output = getOutputs().getSToolObject();
for (Map.Entry> entry : list) {
long where = entry.getKey();
Pair filePosition = filePosition(where);
for (Message msg : entry.getValue()) {
if (msg.kind() == WARNING && ignoreWarnings) {
continue;
}
if (msg.kind() == ERROR) {
output = getOutputs().getEToolObject();
nErrors++;
}
nWarnings += msg.kind() == WARNING ? 1 : 0;
if (where == NOWHERE) {
// direct message isn't connected to a position in a scanned file
output.printlns(msg.text());
} else {
output.printlns(format("%s (%d:%d) %s", getSimpleInputFileName(),
filePosition.first, filePosition.second,
msg.text()));
printAffectedSourceLine(output, filePosition);
}
}
}
DualStreamToolOutput totalOutput = (printTotals) ? getOutputs() : null;
if (printTotals) {
if (nWarnings != 0)
totalOutput.printe(format("%d warning(s)%s", nWarnings, nErrors != 0 ? ", " : "\n"));
if (nErrors != 0)
totalOutput.printlne(format("%d error(s)", nErrors));
}
synchronized (output) {
output.flush();
if (totalOutput != null) {
totalOutput.flush();
}
container.clear();
}
return nErrors;
}
// Removes tabs from a source line to get the correct line position while printing.
private void printAffectedSourceLine(ToolOutput output, Pair filePosition) {
int ln = (int) (filePosition.first - 1);
boolean eof = filePosition.first > fileContent.size();
String line = fileContent.get(min(fileContent.size() - 1, ln));
long countOfExtraSpaces = line.chars().filter(ch -> ch == '\t').count();
line = line.replace("\t", TAB_REPLACEMENT);
long linePosition = (eof) ? line.length() :
(filePosition.second + countOfExtraSpaces * TAB_REPLACEMENT.length()) - countOfExtraSpaces;
output.printlns(line);
output.printlns(repeat(" ", (int) linePosition) + "^");
}
/**
* Insert a message in the list of outstanding messages. The list is sorted on input position.
*/
private void insert(long where, Message message) {
if (where != NOWHERE && fileContent.isEmpty()) {
addToContainer(NOWHERE,
new Message(ERROR, EMessageFormatter.LONG.apply(ERROR, this.getProgramName(),
"Content of the file %s not found", getSimpleInputFileName())));
where = NOWHERE;
}
// message format
addToContainer(where, new Message(message.kind(), where == NOWHERE ?
EMessageFormatter.VERBOSE.apply(this.getProgramName(), message) :
EMessageFormatter.LONG.apply(this.getProgramName(), message)));
}
private void addToContainer(long where, Message msg) {
Set messages = container.get(where);
if (messages != null) {
messages.add(msg);
} else {
Set msgSet = new HashSet<>(1);
msgSet.add(msg);
container.put(where, msgSet);
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/Decoder.java 0000664 0000000 0000000 00000003301 15143236361 0025757 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import static org.openjdk.asmtools.common.Environment.OK;
public abstract class Decoder> extends Tool {
protected Decoder(ToolOutput toolOutput, DualStreamToolOutput outerLog) {
super(toolOutput, outerLog);
}
// Runs the decoder with args
public synchronized boolean decode(String... argv) {
parseArgs(argv);
return this.decode() == OK;
}
// Run a decoder when args already parsed
public abstract int decode();
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/DecompilerLogger.java 0000664 0000000 0000000 00000017552 15143236361 0027652 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.inputs.ToolInput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.regex.Matcher;
import static java.lang.Math.max;
import static java.lang.String.format;
import static org.openjdk.asmtools.common.EMessageKind.ERROR;
import static org.openjdk.asmtools.common.EMessageKind.WARNING;
import static org.openjdk.asmtools.common.Environment.OK;
public class
DecompilerLogger extends ToolLogger implements ILogger {
// Message Container
private final LinkedHashSet messages = new LinkedHashSet();
private Consumer addToContainer = (String msg) -> {
if (msg != null) {
messages.add(msg);
}
};
/**
* @param programName the tool name
* @param cls the environment class of the tool for which to obtain the resource bundle
* @param outerLog the logger stream
*/
public DecompilerLogger(String programName, Class cls, DualStreamToolOutput outerLog) {
super(programName, cls, outerLog);
}
@Override
public void warning(String id, Object... args) {
String msg = getResourceString(id, args);
if (msg == null) {
if (EMessageKind.isFromResourceBundle(id)) {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR,
"(I18NResourceBundle) The warning message '%s' not found", id);
} else {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.WARNING, super.getProgramName(), format(id, args));
}
} else {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.WARNING, super.getProgramName(), msg);
}
addToContainer.accept(msg);
}
@Override
public void error(String id, Object... args) {
String msg = getResourceString(id, args);
if (msg == null) {
if (EMessageKind.isFromResourceBundle(id)) {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR,
super.getProgramName(),
"(I18NResourceBundle) The error message '%s' not found", id);
} else {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR, super.getProgramName(), format(id, args));
}
} else {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR, super.getProgramName(), msg);
}
addToContainer.accept(msg);
}
@Override
public void info(String id, Object... args) {
String msg = getResourceString(id, args);
if (msg == null) {
if (EMessageKind.isFromResourceBundle(id)) {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR,
super.getProgramName(),
"(I18NResourceBundle) The error message '%s' not found", id);
} else {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR, super.getProgramName(), format(id, args));
}
} else {
msg = EMessageFormatter.SHORT.apply(EMessageKind.ERROR, super.getProgramName(), msg);
}
addToContainer.accept(msg);
}
@Override
public void printErrorLn(String format, Object... args) {
String msg = (args == null || args.length == 0) ? format : format(format, args);
addToContainer.accept(msg);
}
@Override
public void error(Throwable exception) {
String msg = ToolLogger.EMessageFormatter.VERBOSE.apply(ERROR, super.getProgramName(), exception.getMessage());
addToContainer.accept(msg);
}
@Override
public String getInfo(String id, Object... args) {
String message = getResourceString(id, args);
if (message == null) {
String msg;
if (EMessageKind.isFromResourceBundle(id)) {
msg = EMessageFormatter.VERBOSE.apply(EMessageKind.ERROR, super.getProgramName(),
"(I18NResourceBundle) The error message '%s' not found", id);
} else {
msg = (args == null || args.length == 0) ? id : format(id, args);
}
addToContainer.accept(msg);
}
return message;
}
@Override
public long getCount(EMessageKind kind) {
return messages.stream().filter(msg -> msg.contains(kind.shortForm())).count();
}
public int registerTotalIssues(int rc, ToolInput toolInput) {
int ret = OK;
int nErrors = (int) getCount(ERROR);
int nWarnings = (int) getCount(WARNING);
if (nWarnings > 0 || nErrors > 0) {
// don't take into account warnings
ret = max(rc, nErrors);
String sWarnings = (nWarnings > 0) ?
"%d warning(s)".formatted(nWarnings).concat((nErrors > 0) ? ", " : "") : "";
String sErrors = (nErrors > 0) ? "%d error(s) ".formatted(nErrors) : " ";
info("err.count.issues", sWarnings, sErrors, toolInput);
}
return ret;
}
public synchronized void flush() {
if (!messages.isEmpty()) {
DualStreamToolOutput output = getOutputs();
// output.printe('\n');
for (String msg : messages) {
output.printlne(msg);
}
synchronized (output) {
output.flush();
messages.clear();
}
}
}
@Override
public void usage(List usageIDs) {
usage(usageIDs, id -> getInfo(id));
}
@Override
public void usage(List usageIDs, Function func) {
for (String id : usageIDs) {
String s = func.apply(id);
if (s != null) {
Matcher m = usagePattern.matcher(s);
if (m.find()) {
println(format(" %-21s %s", m.group(1).trim(), m.group(2).trim()));
if (s.contains("\n")) {
// multiline
String[] lines = s.split("\\n");
for (int i = 1; i < lines.length; i++) {
println(format("%s%s", " ".repeat(24), lines[i].trim()));
}
}
} else {
String[] lines = s.split("\\n");
if (lines.length > 1 && lines[0].trim().startsWith("-")) {
println(format(" %s", lines[0].trim()));
for (int i = 1; i < lines.length; i++) {
println(format("%s%s", " ".repeat(24), lines[i].trim()));
}
} else {
println(s);
}
}
}
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/EMessageKind.java 0000664 0000000 0000000 00000001252 15143236361 0026714 0 ustar 00root root 0000000 0000000 package org.openjdk.asmtools.common;
public enum EMessageKind {
ERROR("err."),
WARNING("warn."),
INFO("info.");
final String prefix;
EMessageKind(String prefix) {
this.prefix = prefix;
}
public static boolean isFromResourceBundle(String msg) {
for (EMessageKind kind : values()) {
if (msg.startsWith(kind.prefix)) {
return true;
}
}
return false;
}
public String longForm() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
public String shortForm() {
return name().length() > 5 ? name().substring(0, 4) : name();
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/Environment.java 0000664 0000000 0000000 00000014556 15143236361 0026734 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.inputs.ToolInput;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
public abstract class Environment implements ILogger {
// Results
public final static int OK = 0;
public final static int FAILED = 1;
T toolLogger;
//-w Specify where to place generated class files, without considering the classpath.
// If not specified, output will be directed to .
private boolean ignorePackage = false;
// processed input file or stdin
private ToolInput toolInput;
private ToolOutput toolOutput;
// checks output verbosity
private boolean verboseFlag;
public boolean isTraceFlag() {
return traceFlag;
}
private boolean traceFlag;
/**
* @param builder the environment builder
*/
protected Environment(Builder builder) {
this.toolOutput = builder.toolOutput;
this.toolLogger = (T) builder.toolLogger;
}
public void setToolInput(ToolInput toolInput) throws IOException, URISyntaxException {
this.toolInput = toolInput;
toolLogger.setInputFileName(toolInput);
}
public void setTraceFlag(boolean flag) {
this.traceFlag = flag;
}
public void setIgnoreWarningsOn() {
toolLogger.ignoreWarnings = true;
}
public void setStrictWarningsOn() {
toolLogger.strictWarnings = true;
}
public boolean isIgnorePackage() {
return ignorePackage;
}
public Environment setIgnorePackage(boolean ignorePackage) {
this.ignorePackage = ignorePackage;
return this;
}
public String getSimpleInputFileName() {
return toolLogger.getSimpleInputFileName();
}
/**
* Returns the name of the source file that is used by the tool to assemble the SourceFile attribute
*
* @return the name of the source file
*/
public String getSourceName() {
String sourceFileName = getSimpleInputFileName();
String sourceName = sourceFileName.contains(".") ?
sourceFileName.substring(0, sourceFileName.indexOf('.')) :
sourceFileName;
return sourceName;
}
public ToolInput getToolInput() {
return toolInput;
}
/**
* @return DataInputStream or null if the method can't read a file
*/
protected DataInputStream getDataInputStream() throws URISyntaxException, IOException {
Objects.requireNonNull(this.toolInput, "Input must be defined.");
return toolInput.getDataInputStream(Optional.of(this));
}
@Override
public void traceln(String id, Object... args) {
if (traceFlag)
ILogger.super.traceln(id, args);
}
public void traceln(Supplier supplier) {
if (traceFlag) {
ILogger.super.traceln(supplier.get());
}
}
@Override
public void trace(String id, Object... args) {
if (traceFlag)
ILogger.super.trace(id, args);
}
@Override
public void error(String id, Object... args) {
toolLogger.error(id, args);
}
@Override
public void error(Throwable exception) {
toolLogger.error(exception);
}
public void trace(Supplier supplier) {
if (traceFlag) {
ILogger.super.trace(supplier.get());
}
}
@Override
public void info(String id, Object... args) {
toolLogger.info(id, args);
}
public String getInfo(String id, Object... args) {
return toolLogger.getInfo(id, args);
}
public void usage(List ids) {
toolLogger.usage(ids);
}
public void usage(List ids, Function func) {
toolLogger.usage(ids, func);
}
@Override
public void printException(Throwable throwable) {
if (verboseFlag)
toolLogger.printException(throwable);
}
@Override
public DualStreamToolOutput getOutputs() {
return getLogger().getOutputs();
}
@Override
public void setOutputs(DualStreamToolOutput nw) {
getLogger().setOutputs(nw);
}
@Override
public ToolOutput getToolOutput() {
return toolOutput;
}
@Override
public void setToolOutput(ToolOutput toolOutput) {
this.toolOutput = toolOutput;
}
public boolean getVerboseFlag() {
return verboseFlag;
}
public Environment setVerboseFlag(boolean value) {
this.verboseFlag = value;
return this;
}
public T getLogger() {
return (T) toolLogger;
}
/**
* The Environment builder.
*/
public abstract static class Builder {
T toolLogger;
public ToolOutput toolOutput;
public Builder(ToolOutput toolOutput, T toolLogger) {
this.toolOutput = toolOutput;
this.toolLogger = toolLogger;
}
/**
* @return new environment
*/
abstract public E build();
}
} // end Environment
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/ErrorMessage.java 0000664 0000000 0000000 00000000540 15143236361 0027012 0 ustar 00root root 0000000 0000000 package org.openjdk.asmtools.common;
/**
* A sorted list of error messages
*/
public final class ErrorMessage {
public int where;
public String message;
public ErrorMessage next;
/**
* Constructor
*/
public ErrorMessage(int where, String message) {
this.where = where;
this.message = message;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/FormatError.java 0000664 0000000 0000000 00000004045 15143236361 0026662 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
/**
* FormatError is the generic error thrown by jdis, jdec while parsing a class file.
*/
public class FormatError extends ClassFormatError {
/**
* Checks and returns formatted string if id isn't a reference in i18n.properties
*
* @param id either format string or a resource id
* @param args arguments of the format string
* @return null id isn't format string otherwise formatted string
*/
private static String getResourceMsg(String id, Object... args) {
return id.startsWith("err.") || id.startsWith("warn.") ? null : String.format(id, args);
}
public FormatError(T logger, String id, Object... args) {
super( logger.getResourceString(id, args) == null ?
(FormatError.getResourceMsg(id, args) == null ? "(i18n.properties) The message '" + id + "' not found" : FormatError.getResourceMsg(id, args))
: logger.getResourceString(id, args));
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/ILogger.java 0000664 0000000 0000000 00000007665 15143236361 0025763 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import java.util.regex.Pattern;
import static java.lang.String.format;
public interface ILogger {
// A logged message isn't attached to a position of a parsed file
int NOWHERE = Integer.MAX_VALUE;
// Replacement for the tab found in an input
CharSequence TAB_REPLACEMENT = " ".repeat(4);
Pattern usagePattern = Pattern.compile("(-\\S+\\p{Blank}*\\S*)\\p{Blank}+([PGSDCSOIU]+.*)");
default String getResourceString(String id, Object... args) {
throw new NotImplementedException();
}
default void warning(long where, String id, Object... args) {
throw new NotImplementedException();
}
default void error(long where, String id, Object... args) {
throw new NotImplementedException();
}
default void info(String id, Object... args) {
String message = getInfo(id, args);
if (message != null) {
println(message);
}
}
default long getCount(EMessageKind kind) {
throw new NotImplementedException();
}
default String getInfo(String id, Object... args) {
throw new NotImplementedException();
}
default void warning(String id, Object... args) {
throw new NotImplementedException();
}
default void error(String id, Object... args) {
throw new NotImplementedException();
}
default void error(Throwable exception) {
error(NOWHERE, exception.getMessage());
}
default void traceln(String format, Object... args) {
getOutputs().printlne((args == null || args.length == 0) ? format : format(format, args));
;
}
default void trace(String format, Object... args) {
getOutputs().printe((args == null || args.length == 0) ? format : format(format, args));
}
default void printErrorLn(String format, Object... args) {
getOutputs().printlne((args == null || args.length == 0) ? format : format(format, args));
}
default void println(String format, Object... args) {
getOutputs().printlns((args == null || args.length == 0) ? format : format(format, args));
}
default void println() {
getOutputs().printlns("");
}
default void print(String format, Object... args) {
getOutputs().prints((args == null || args.length == 0) ? format : format(format, args));
}
default void print(char ch) {
getOutputs().prints(ch);
}
DualStreamToolOutput getOutputs();
void setOutputs(DualStreamToolOutput nwoutput);
default ToolOutput getToolOutput() {
throw new NotImplementedException("implement wisely!");
}
default void setToolOutput(ToolOutput toolOutput) {
throw new NotImplementedException("implement wisely!");
}
void printException(Throwable throwable);
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/NotImplementedException.java 0000664 0000000 0000000 00000000516 15143236361 0031222 0 ustar 00root root 0000000 0000000 package org.openjdk.asmtools.common;
/** class used to indicate missing functionality */
public class NotImplementedException extends RuntimeException {
public NotImplementedException() {
super("The method is not yet implemented");
}
public NotImplementedException(String reason) {
super(reason);
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/SyntaxError.java 0000664 0000000 0000000 00000002654 15143236361 0026724 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
/**
* SyntaxError is the generic error thrown by jasm, jcoder while parsing either a jasm file or jcod file.
*/
public class SyntaxError extends Error {
private boolean fatalError = false;
public SyntaxError setFatal() {
this.fatalError = true;
return this;
}
public boolean isFatal() {
return this.fatalError;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/Tool.java 0000664 0000000 0000000 00000007331 15143236361 0025336 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.inputs.StdinInput;
import org.openjdk.asmtools.common.inputs.ToolInput;
import org.openjdk.asmtools.common.outputs.FSOutput;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import java.io.File;
import java.util.ArrayList;
import static org.openjdk.asmtools.common.outputs.FSOutput.FSDestination.DIR;
public abstract class Tool> {
protected final ArrayList fileList = new ArrayList<>();
protected T environment;
private ToolOutput toolOutput;
protected Tool(ToolOutput toolOutput, DualStreamToolOutput outerLog) {
this.environment = getEnvironment(toolOutput, outerLog);
}
public Environment> setVerboseFlag(boolean value) {
environment.setVerboseFlag(value);
return environment;
}
public Environment> setTraceFlag(boolean value) {
environment.setTraceFlag(value);
return environment;
}
public T getEnvironment() {
return environment;
}
// Build environment
public T getEnvironment(ToolOutput toolOutput, DualStreamToolOutput outerLog) {
throw new NotImplementedException();
}
// Usage
protected abstract void usage();
// Parse arguments. The Tool will be left using System.Exit if an error is found.
protected abstract void parseArgs(String... argv);
protected void setFSDestination(FSOutput.FSDestination destination, int index, String... argv) {
File file;
if ((index) >= argv.length) {
environment.error(destination == FSOutput.FSDestination.FILE ? "err.f_requires_argument" : "err.d_requires_argument");
usage();
throw new IllegalArgumentException();
}
String fname = argv[index];
file = new File(fname);
if (destination == DIR && !file.exists()) {
environment.error("err.does_not_exist", fname);
throw new IllegalArgumentException();
}
if (toolOutput == null) {
toolOutput = new FSOutput();
}
switch (destination) {
case FILE:
environment.setToolOutput(((FSOutput) toolOutput).setFile(new File("."), fname));
break;
case DIR:
environment.setToolOutput(((FSOutput) toolOutput).setDir(file));
}
}
protected void addStdIn() {
for (ToolInput toolInput : fileList) {
if (toolInput instanceof StdinInput) {
//or throw?
return;
}
}
fileList.add(new StdinInput());
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/ToolLogger.java 0000664 0000000 0000000 00000015204 15143236361 0026474 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import org.openjdk.asmtools.common.inputs.ToolInput;
import org.openjdk.asmtools.common.outputs.log.DualStreamToolOutput;
import org.openjdk.asmtools.util.I18NResourceBundle;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import static java.lang.String.format;
import static org.openjdk.asmtools.Main.sharedI18n;
import static org.openjdk.asmtools.common.EMessageKind.ERROR;
import static org.openjdk.asmtools.common.EMessageKind.INFO;
public abstract class ToolLogger implements ILogger {
protected boolean ignoreWarnings = false; // do not print / ignore warnings
protected boolean strictWarnings = false; // consider warnings as errors
class ToolResources {
private final static HashMap resources = new HashMap<>();
public ToolResources(String programName, Class cls) {
if (!ToolResources.resources.containsKey(programName)) {
ToolResources.resources.put(programName, I18NResourceBundle.getBundleForClass(cls));
}
}
public void setWarn(boolean value) {
ToolResources.resources.get(ToolLogger.this.programName).setWarn(value);
}
public String getString(String id, Object... args) {
return ToolResources.resources.get(ToolLogger.this.programName).getString(id, args);
}
public boolean containsKey(String key) {
return ToolResources.resources.get(ToolLogger.this.programName).containsKey(key);
}
}
private final String programName;
private ToolResources toolResources;
DualStreamToolOutput outerLog;
// Input file name is needed for logging purposes
private String inputFileName;
private String simpleInputFileName;
static {
sharedI18n.setWarn(false);
}
/**
* @param programName the tool name
* @param cls the environment class of the tool for which to obtain the resource bundle
* @param outerLog the logger stream
*/
public ToolLogger(String programName, Class cls, DualStreamToolOutput outerLog) {
// Set Resource bundle for the tool
this.toolResources = new ToolResources(programName, cls);
this.programName = programName;
this.outerLog = outerLog;
}
@Override
public String getResourceString(String id, Object... args) {
String resString;
toolResources.setWarn(false);
try {
resString = toolResources.getString(id, args);
} finally {
toolResources.setWarn(true);
}
if (resString == null || resString.equals(id)) {
resString = sharedI18n.getString(id, args);
}
if (resString == null || resString.equals(id)) {
//to get a proper error message
resString = toolResources.getString(id, args);
}
return resString;
}
public void setInputFileName(ToolInput inputFileName) throws IOException {
this.inputFileName = inputFileName.getName();
this.simpleInputFileName = Paths.get(inputFileName.getName()).getFileName().toString();
// the content of the input file will be loaded only if the file is parsed by jasm/jcoder
}
public Message getResourceString(EMessageKind kind, String id, Object... args) {
String str;
for (String prefix : Set.of("", kind.prefix)) {
if (toolResources.containsKey(prefix + id) || sharedI18n.containsKey(prefix + id)) {
str = getResourceString(id, args);
if (str != null) {
return new Message(kind, str);
}
}
}
return new Message(ERROR, null);
}
@Override
public DualStreamToolOutput getOutputs() {
return outerLog;
}
@Override
public void setOutputs(DualStreamToolOutput nwoutput) {
this.outerLog = nwoutput;
}
public String getSimpleInputFileName() {
return simpleInputFileName;
}
@Override
public void printException(Throwable throwable) {
getOutputs().stacktrace(throwable);
}
public String getProgramName() {
return programName;
}
public abstract void usage(List ids);
public abstract void usage(List ids, Function func);
public enum EMessageFormatter {
SHORT((severity, name, message) -> format("%s", message)),
LONG((severity, name, message) -> format("%s: %s", severity.longForm(), message)),
VERBOSE((severity, name, message) -> severity == INFO ? message :
format("%-7s-%6s: %s", name, severity.shortForm(), message));
final private TriFunction triFunc;
EMessageFormatter(TriFunction func) {
this.triFunc = func;
}
public String apply(EMessageKind kind, String name, String format, Object... args) {
return (format == null || name == null) ? "" : triFunc.apply(kind, name, format(format, args));
}
public String apply(String name, Message message) {
return message.notFound() ? "" : triFunc.apply(message.kind(), name, message.text());
}
}
public record Message(EMessageKind kind, String text) {
Message(EMessageKind kind, String format, Object... args) {
this(kind, format(format, args));
}
public boolean notFound() {
return kind == ERROR && text == null;
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/TriFunction.java 0000664 0000000 0000000 00000002757 15143236361 0026674 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
@FunctionalInterface
public interface TriFunction {
R apply(T t, U u, V v);
// Default method to compose functions (like BiFunction.andThen)
default TriFunction andThen(java.util.function.Function super R, ? extends W> after) {
if (after == null) throw new NullPointerException("After function must not be null");
return (t, u, v) -> after.apply(apply(t, u, v));
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/ 0000775 0000000 0000000 00000000000 15143236361 0025074 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/ByteInput.java 0000664 0000000 0000000 00000006616 15143236361 0027673 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, 2025, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
import org.openjdk.asmtools.common.Environment;
import java.io.*;
import java.net.URISyntaxException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
public class ByteInput implements ToolInput {
private boolean detailedInput = false;
private MessageDigest md = null;
//compilers passes input more than one times, so saving it for reuse;
protected byte[] bytes;
public ByteInput(final byte[] bytes) {
this.bytes = bytes;
}
protected ByteInput() {
}
public byte[] getBytes() {
return bytes;
}
public ByteInput setDetailedInput(boolean detailedInput) {
this.detailedInput = detailedInput;
return this;
}
@Override
public MessageDigest getMessageDigest() {
return md;
}
@Override
public int getSize() {
return bytes.length;
}
@Override
public String getName() {
//get parent is used
return "bytes/bytes";
}
@Override
public String toString() {
return getName();
}
protected void init() {
}
@Override
public DataInputStream getDataInputStream(Optional logger) {
init();
try {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
if (detailedInput) {
md = MessageDigest.getInstance("SHA-256");
DigestInputStream dis = new DigestInputStream(bais, md);
return new DataInputStream(dis);
} else {
return new DataInputStream(bais);
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public Collection readAllLines() throws IOException {
init();
ArrayList resultingLines = new ArrayList();
try (BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes), "utf-8"))) {
while (true) {
String l = br.readLine();
if (l == null) {
break;
}
resultingLines.add(l);
}
}
return resultingLines;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/FileInput.java 0000664 0000000 0000000 00000010553 15143236361 0027642 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
import org.openjdk.asmtools.common.Environment;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Optional;
public class FileInput implements ToolInput {
private boolean detailedInput = false;
private final String fileName;
private MessageDigest md = null;
private CapacityInputStream cis = null;
public FileInput(String fileName) {
this.fileName = fileName;
}
@Override
public String getName() {
return fileName;
}
public Collection readAllLines() throws IOException {
return Files.readAllLines(Paths.get(getName()));
}
public FileInput setDetailedInput(boolean detailedInput) {
this.detailedInput = detailedInput;
return this;
}
@Override
public MessageDigest getMessageDigest() {
return md;
}
@Override
public int getSize() {
return cis != null ? cis.size() : 0;
}
@Override
public DataInputStream getDataInputStream(Optional logger) throws URISyntaxException, IOException {
try {
FileInputStream fis = new FileInputStream(this.getName());
if (detailedInput) {
cis = new CapacityInputStream(fis);
md = MessageDigest.getInstance("SHA-256");
DigestInputStream dis = new DigestInputStream(cis, md);
return new DataInputStream(dis);
} else {
return new DataInputStream(fis);
}
} catch (IOException ex) {
if (this.getName().matches("^[A-Za-z]+:.*")) {
try {
final URI uri = new URI(this.getName());
final URL url = uri.toURL();
final URLConnection conn = url.openConnection();
conn.setUseCaches(false);
return new DataInputStream(conn.getInputStream());
} catch (URISyntaxException | IOException exception) {
if (logger.isPresent()) {
logger.get().error("err.cannot.read", this.getName());
}
throw exception;
}
} else {
throw ex;
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public String toString() {
return getName();
}
private static class CapacityInputStream extends FilterInputStream {
CapacityInputStream(InputStream in) {
super(in);
}
int size() {
return size;
}
@Override
public int read(byte[] buf, int offset, int length) throws IOException {
int n = super.read(buf, offset, length);
if (n > 0)
size += n;
return n;
}
@Override
public int read() throws IOException {
int b = super.read();
size += 1;
return b;
}
private int size;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/StdinInput.java 0000664 0000000 0000000 00000002456 15143236361 0030047 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
public class StdinInput extends StreamInput {
public StdinInput() {
super(System.in);
}
@Override
public String getName() {
//get parent is used
return "stdin/stdin";
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/StreamInput.java 0000664 0000000 0000000 00000004010 15143236361 0030205 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
public class StreamInput extends ByteInput {
private final InputStream originalStream;
public StreamInput(InputStream is) {
originalStream = is;
}
@Override
protected void init() {
if (bytes == null) {
bytes = drainIs(originalStream);
}
}
public static byte[] drainIs(InputStream is) {
try {
byte[] buffer = new byte[32 * 1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead;
while ((bytesRead = is.read(buffer)) > 0) {
baos.write(buffer, 0, bytesRead);
}
return baos.toByteArray();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
@Override
public String getName() {
//get parent is used
return "stream/stream";
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/StringInput.java 0000664 0000000 0000000 00000002613 15143236361 0030227 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
import java.nio.charset.StandardCharsets;
public class StringInput extends ByteInput {
public StringInput(final String bytes) {
super(bytes.getBytes(StandardCharsets.UTF_8));
}
@Override
public String getName() {
//get parent is used
return "string/string";
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/TextInput.java 0000664 0000000 0000000 00000003463 15143236361 0027711 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* Base class for JasmEnvironment.InputFile and
* JcoderEnvironment.InputFile that read the jasm, jcod text files
*/
public abstract class TextInput {
public long position;
protected int charPos = 0;
protected int linepos = 1;
// Buffer to keep the text file content
protected final String strData;
public TextInput(DataInputStream dataInputStream) throws IOException {
byte[] data = new byte[dataInputStream.available()];
dataInputStream.read(data);
strData = new String(data, StandardCharsets.UTF_8);
dataInputStream.close();
}
public abstract int readUTF();
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/inputs/ToolInput.java 0000664 0000000 0000000 00000004471 15143236361 0027702 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.inputs;
import org.openjdk.asmtools.common.Environment;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.util.Collection;
import java.util.Optional;
/**
* This class is a generic interface, symbolising any input for jdis/jasm/jdec/jcoder.
* Asmtools as application internally uses FileInput and StdinInput.
* UnitTests for asmtools uses mainly StringInput for assemblers and ByteInput for disassemblers.
*
* String/Byte/Stream inputs can be used as any 3rd part code which do not need files, aka IDE, instrumentation or similar.
*
* The interface methods goes in favor of asmtools, and for details and help see individual implementations
*/
public interface ToolInput {
String getName();
DataInputStream getDataInputStream(Optional logger) throws URISyntaxException, IOException;
Collection readAllLines() throws IOException;
default boolean isDetailedInput() {
return false;
}
default ToolInput setDetailedInput(boolean value) {
return this;
}
default MessageDigest getMessageDigest() {
return null;
}
default int getSize() {
return 0;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/ 0000775 0000000 0000000 00000000000 15143236361 0025275 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/ByteOutput.java 0000664 0000000 0000000 00000007675 15143236361 0030303 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, 2025, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.Environment;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Optional;
import java.util.stream.Collectors;
public class ByteOutput extends NamedToolOutput {
private final ArrayList outputs = new ArrayList<>();
private ByteArrayOutputStream currentClass;
public ArrayList getOutputs() {
return outputs;
}
@Override
public String toString() {
return outputs.stream().map(a -> a.toString()).collect(Collectors.joining(System.lineSeparator()));
}
@Override
public DataOutputStream getDataOutputStream() throws FileNotFoundException {
return new DataOutputStream(currentClass);
}
@Override
public void startClass(String fullyQualifiedName, Optional suffix, Environment logger) throws IOException {
super.startClass(fullyQualifiedName, suffix, logger);
currentClass = new ByteArrayOutputStream(1024);
}
@Override
public void finishClass(String fullyQualifiedName) throws IOException {
String fqn = getCurrentClassName();
if ( fqn != null && !fqn.equals(fullyQualifiedName)) {
throw new RuntimeException("Ended different class: %s then was started %s".
formatted(fullyQualifiedName, fqn));
}
if (currentClass != null) {
outputs.add(new NamedBinary(fullyQualifiedName, currentClass.toByteArray()));
}
super.finishClass(fullyQualifiedName);
currentClass = null;
}
@Override
public void printlns(String line) {
try {
currentClass.write((line + System.lineSeparator()).getBytes(StandardCharsets.UTF_8));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
@Override
public void prints(String line) {
try {
currentClass.write(line.getBytes(StandardCharsets.UTF_8));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
@Override
public void prints(char line) {
currentClass.write(line);
}
@Override
public void flush() {
}
@Override
public String getName() {
return "byte stream";
}
public class NamedBinary {
private final String fqn;
private final byte[] body;
public NamedBinary(String fqn, byte[] body) {
this.fqn = fqn;
this.body = body;
}
public String getFqn() {
return fqn;
}
public byte[] getBody() {
return body;
}
@Override
public String toString() {
return fqn + ": " + body.length + "b";
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/EscapedPrintStreamOutput.java 0000664 0000000 0000000 00000003610 15143236361 0033116 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.uEscWriter;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
public class EscapedPrintStreamOutput extends PrintWriterOutput {
private final OutputStream originalStream;
public EscapedPrintStreamOutput(OutputStream os) {
super(new uEscWriter(os));
this.originalStream = os;
}
@Override
public DataOutputStream getDataOutputStream() throws FileNotFoundException {
return new DataOutputStream(new BufferedOutputStream(originalStream));
}
@Override
public void finishClass(String fullyQualifiedName) throws IOException {
super.finishClass(fullyQualifiedName);
originalStream.flush();
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/FSOutput.java 0000664 0000000 0000000 00000014662 15143236361 0027702 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, 2025, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.Environment;
import java.io.*;
import java.nio.file.FileSystems;
import java.nio.file.Paths;
import java.util.Optional;
/**
* A concrete implementation of {@link NamedToolOutput} that writes output to a file system.
*
* @author Leonid Kuskov
*/
public class FSOutput extends NamedToolOutput {
private FSDestination destination;
private File dir;
private File file;
private FileOutputStream fos;
private PrintWriter pw;
private static final String fileSeparator = FileSystems.getDefault().getSeparator();
public FSOutput() {
}
@Override
public boolean isReady() {
return pw != null;
}
public FSOutput setFile(File dir, String file) {
if (this.dir == null)
this.dir = dir;
destination = FSDestination.FILE;
setDestinationFileName(file);
return this;
}
public FSOutput setDir(File dir) {
this.dir = dir;
if (destination == null) {
destination = FSDestination.DIR;
}
return this;
}
public File getDir() {
return dir;
}
@Override
public String toString() {
String str = super.toString();
if (dir != null && file != null) {
str.concat(dir != null ? dir.toString() : "").
concat(fileSeparator).
concat(file != null ? file.toString() : "");
}
return str;
}
@Override
public void printlns(String line) {
pw.println(line);
}
@Override
public void prints(String line) {
pw.print(line);
}
@Override
public void prints(char line) {
pw.print(line);
}
/**
* Starts writing a new class file with the specified fully qualified name and optional file extension.
*
* @param fullyQualifiedName the fully qualified name of the class
* @param fileExtension the optional file extension
* @param environment the current environment
* @throws IOException if an I/O error occurs
*/
@Override
public void startClass(String fullyQualifiedName, Optional fileExtension, Environment environment) throws IOException {
super.startClass(fullyQualifiedName, fileExtension, environment);
String packageName, fileName;
int index = fullyQualifiedName.lastIndexOf(fileSeparator);
if (index != -1) {
packageName = environment.isIgnorePackage() ? "" : fullyQualifiedName.substring(0, index);
fileName = fullyQualifiedName.substring(index + 1);
} else {
packageName = "";
fileName = fullyQualifiedName;
}
/**
* The destinationFileName is used to form the filename of the output.
* 1. File FILENAME or class file CLASSNAME takes the highest priority. This filename cannot be overridden.
* 2. Public class CLASSNAME { }– class name is CLASSNAME, and this CLASSNAME will be used to generate the filename (i.e., CLASSNAME.class).
* 3. this_class – The filename will be CLASSNAME.class, but the class name will be this_class.
*
* Also, if the -f option is used and the number of processed class files is more than 1,
* then destinationFileName will only apply to the first input file only.
* For example, if you run jdis -w . -f FILE input.class input2.class, then in the output directory,
* the files FILE.jasm and input2.jasm will be generated.
*/
String destinationFileName = this.getDestinationFileName();
if (destinationFileName != null) {
fileName = destinationFileName + fileExtension.orElse("");
} else {
fileName = fileName + fileExtension.orElse("");
}
if (dir == null) {
environment.traceln("writing to %s %s".formatted(packageName, fileName));
file = new File(packageName, fileName);
} else {
file = Paths.get(dir.getPath(), packageName, fileName).toFile();
environment.traceln(() -> "writing -d %s = \"%s\"".formatted(dir.getPath(), file.getAbsolutePath()));
File outDir = new File(file.getParent());
if (!outDir.exists() && !outDir.mkdirs()) {
environment.error("err.cannot.create", outDir.getPath());
return;
}
}
fos = new FileOutputStream(file);
pw = new PrintWriter(new OutputStreamWriter(fos));
}
@Override
public void finishClass(String fullyQualifiedName) throws IOException {
super.finishClass(fullyQualifiedName);
flush();
try {
if (pw != null) {
pw.close();
}
} finally {
if (fos != null) {
fos.close();
}
}
}
@Override
public void flush() {
if (fos != null) {
try {
fos.flush();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
@Override
public DataOutputStream getDataOutputStream() throws FileNotFoundException {
return new DataOutputStream(new BufferedOutputStream(fos));
}
@Override
public String getName() {
return ( file !=null ) ? file.toString() : "file stream";
}
public enum FSDestination {
FILE, DIR;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/NamedToolOutput.java 0000664 0000000 0000000 00000006416 15143236361 0031252 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, 2025, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.Environment;
import java.io.IOException;
import java.util.Optional;
/**
* Historically, the output loggers for compilers had two stderrs, one to stdout and second to stderr.
* That should be removed, in favour of just dual stream tool output, printing output to stdout and log into stderr
*/
public abstract class NamedToolOutput implements ToolOutput {
protected String fullyQualifiedName = "";
/**
* If the output is a file, then the destinationFileName is used to form the filename of the output.
* 1. File FILENAME or class file CLASSNAME takes the highest priority. This filename cannot be overridden.
* 2. Public class CLASSNAME { }– class name is CLASSNAME, and this CLASSNAME will be used to generate the filename (i.e., CLASSNAME.class).
* 3. this_class – The filename will be CLASSNAME.class, but the class name will be this_class.
*
* Also, if the -f option is used and the number of processed class files is more than 1,
* then destinationFileName will only apply to the first input file only.
* For example, if you run jdis -w . -f FILE input.class input2.class, then in the output directory,
* the files FILE.jasm and input2.jasm will be generated.
*/
protected String destinationFileName = null;
private Optional suffix;
private Environment environment;
@Override
public String getCurrentClassName() {
return fullyQualifiedName;
}
@Override
public void startClass(String fullyQualifiedName, Optional suffix, Environment logger) throws IOException {
this.fullyQualifiedName = fullyQualifiedName;
this.suffix = suffix;
this.environment = logger;
}
@Override
public void finishClass(String fullyQualifiedName) throws IOException {
this.destinationFileName = null;
this.fullyQualifiedName = null;
}
public String getDestinationFileName() {
return destinationFileName;
}
public NamedToolOutput setDestinationFileName(String destinationFileName) {
this.destinationFileName = destinationFileName;
return this;
}
public abstract String getName();
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/PrintWriterOutput.java 0000664 0000000 0000000 00000004772 15143236361 0031664 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, 2025, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.NotImplementedException;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
public class PrintWriterOutput extends NamedToolOutput {
protected PrintWriter os;
public PrintWriterOutput(OutputStream os) {
//although it is usually System.out, it is set from Environment, or custom
this.os = new PrintWriter(os, true);
}
public PrintWriterOutput(Writer os) {
//although it is usually System.out, it is set from Environment, or custom
this.os = new PrintWriter(os, true);
}
@Override
public void printlns(String line) {
os.println(line);
}
@Override
public void prints(String line) {
os.print(line);
}
@Override
public void prints(char line) {
os.print(line);
}
@Override
public void finishClass(String fullyQualifiedName) throws IOException {
super.finishClass(fullyQualifiedName);
os.flush();
}
@Override
public void flush() {
os.flush();
}
@Override
public DataOutputStream getDataOutputStream() throws FileNotFoundException {
throw new NotImplementedException("Use EscapedPrintStreamOutput");
}
@Override
public String getName() {
return "text-output stream";
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/StdoutOutput.java 0000664 0000000 0000000 00000000254 15143236361 0030644 0 ustar 00root root 0000000 0000000 package org.openjdk.asmtools.common.outputs;
public class StdoutOutput extends EscapedPrintStreamOutput {
public StdoutOutput() {
super(System.out);
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/TextOutput.java 0000664 0000000 0000000 00000012062 15143236361 0030306 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, 2025, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.Environment;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import static java.lang.String.format;
public class TextOutput extends NamedToolOutput {
// decoration for text output
private BiFunction namedSourceOrnament;
private final ArrayList outputs = new ArrayList<>();
private StringBuilder curClsStringBuilder;
public ArrayList getOutputs() {
return outputs;
}
@Override
public String toString() {
return outputs.stream().map(a -> a.toString()).
collect(Collectors.joining(System.lineSeparator()));
}
@Override
public DataOutputStream getDataOutputStream() throws FileNotFoundException {
return null; //If you are here, you probably wanted ToolOutput.ByteOutput for assembled binary output
}
@Override
public void startClass(String fullyQualifiedName, Optional suffix, Environment logger) throws IOException {
super.startClass(fullyQualifiedName, suffix, logger);
curClsStringBuilder = new StringBuilder();
}
@Override
public void finishClass(String fullyQualifiedName) throws IOException {
String fqn = getCurrentClassName();
if (fqn != null && !fqn.equals(fullyQualifiedName)) {
throw new RuntimeException("Ended with a different class: %s; then %s was started.".
formatted(fullyQualifiedName, fqn));
}
if (curClsStringBuilder != null) {
outputs.add(new NamedSource(fullyQualifiedName, curClsStringBuilder.toString(), namedSourceOrnament));
}
super.finishClass(fullyQualifiedName);
curClsStringBuilder = null;
}
public TextOutput setNamedSourceOrnament(BiFunction namedSourceOrnament) {
this.namedSourceOrnament = namedSourceOrnament;
return this;
}
@Override
public void printlns(String line) {
curClsStringBuilder.append(line).append("\n");
}
@Override
public void prints(String line) {
curClsStringBuilder.append(line);
}
@Override
public void prints(char line) {
curClsStringBuilder.append(line);
}
@Override
public void flush() {
}
@Override
public String getName() {
return "string";
}
public class NamedSource {
// decoration for text output
private BiFunction ornament = (fname, body) ->
format(
"""
/**
%s
**/
%s
/**
%s
**/
""", fname, body, fname);
private final String fullyQualifiedName;
private final String body;
public NamedSource(String fullyQualifiedName, String body) {
this.fullyQualifiedName = fullyQualifiedName;
this.body = body;
}
public NamedSource(String fullyQualifiedName, String body, BiFunction ornament) {
this.fullyQualifiedName = fullyQualifiedName;
this.body = body;
this.ornament = ornament;
}
public NamedSource setOrnament(BiFunction ornament) {
this.ornament = ornament;
return this;
}
public String getFullyQualifiedName() {
return fullyQualifiedName;
}
public String getBody() {
return body;
}
@Override
public String toString() {
return ornament == null ? body : ornament.apply(fullyQualifiedName, body);
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/ToolOutput.java 0000664 0000000 0000000 00000005014 15143236361 0030276 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs;
import org.openjdk.asmtools.common.Environment;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
/**
* This class is a generic interface, symbolizing any output from jdis/jasm/jdec/jcoder.
* Asmtools as application internally uses DirOutput and StdoutOutput (via EscapedPrintStreamOutput).
* UnitTests for asmtools uses mainly ByteOutput for assemblers and TextOutput for disassemblers.
*
* Text/Byte/EscapedPrintStream outputs can be used as any 3rd part code that does not need files, aka IDE,
* instrumentation or similar.
*
* The interface methods go in favor of asmtools, and for details and help see individual implementations
*/
public interface ToolOutput {
DataOutputStream getDataOutputStream() throws FileNotFoundException;
String getCurrentClassName();
void startClass(String fullyQualifiedName, Optional suffix, Environment logger) throws IOException;
void finishClass(String fullyQualifiedName) throws IOException;
void printlns(String line);
void prints(String line);
void prints(char line);
void flush();
public static String exToString(Throwable e) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(out, true, StandardCharsets.UTF_8));
return new String(out.toByteArray(), StandardCharsets.UTF_8);
}
default boolean isReady() {
return true;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log/ 0000775 0000000 0000000 00000000000 15143236361 0026056 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log/DualOutputStreamOutput.java 0000664 0000000 0000000 00000006075 15143236361 0033434 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs.log;
import org.openjdk.asmtools.common.outputs.PrintWriterOutput;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
public class DualOutputStreamOutput extends NamedDualStreamToolOutput {
protected PrintWriter os;
protected PrintWriter es;
public DualOutputStreamOutput() {
this(System.out, System.err);
}
//todo, remove once tests asdapts
public DualOutputStreamOutput(PrintWriter os, PrintWriter er) {
this.os = os;
this.es = er;
}
public DualOutputStreamOutput(PrintStream os, PrintStream er) {
//although it is usually System.out, it is set from Environment, or custom
this.os = new PrintWriter(os, true);
//although it is usually System.err, it is set from Environment, or custom
this.es = new PrintWriter(er, true);
}
@Override
public void printlns(String line) {
os.println(line);
}
@Override
public void prints(String line) {
os.print(line);
}
@Override
public void prints(char line) {
os.print(line);
}
@Override
public void printlne(String line) {
es.println(line);
}
@Override
public void printe(String line) {
es.print(line);
}
@Override
public void printe(char line) {
es.print(line);
}
@Override
public void finishClass(String fqn) throws IOException {
super.finishClass(fqn);
try {
os.flush();
} finally {
es.flush();
}
}
@Override
public void stacktrace(Throwable ex) {
ex.printStackTrace(es);
}
@Override
public ToolOutput getSToolObject() {
return new PrintWriterOutput(os);
}
@Override
public ToolOutput getEToolObject() {
return new PrintWriterOutput(es);
}
@Override
public void flush() {
this.os.flush();
this.es.flush();
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log/DualStreamToolOutput.java 0000664 0000000 0000000 00000004527 15143236361 0033051 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs.log;
import org.openjdk.asmtools.common.NotImplementedException;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
/**
* This is special case of output - for log and trace outputs form compilation, not for bytecode/sources themselves.
* Historically, asmtools had duals stream logger, where tracing was polluting stdout.
* This logic is by default off, but can be turned on by secret switch if needed.
* For application, although logging is still done in two streams, the log is united into stderr via StderrLog.
*
* UnitTest and 3rd party applications such as IDE or instrumentation providers s should be using unified StringLog.
*
* Once (if ever) the historical dependants on duality of log are removed, the logger should be simple and direct to a single buffer.
*/
public interface DualStreamToolOutput extends ToolOutput {
void printlne(String line);
void printe(String line);
void printe(char line);
void stacktrace(Throwable ex);
ToolOutput getSToolObject();
ToolOutput getEToolObject();
@Override
default DataOutputStream getDataOutputStream() throws FileNotFoundException {
throw new NotImplementedException("Not going to happen");
}
}
NamedDualStreamToolOutput.java 0000664 0000000 0000000 00000003454 15143236361 0033735 0 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs.log;
import org.openjdk.asmtools.common.Environment;
import java.io.IOException;
import java.util.Optional;
public abstract class NamedDualStreamToolOutput implements DualStreamToolOutput {
private String fqn;
private Optional suffix;
private Environment environment;
@Override
public String getCurrentClassName() {
return fqn;
}
@Override
public void startClass(String fullyQualifiedName, Optional suffix, Environment logger) throws IOException {
this.fqn = fullyQualifiedName;
this.suffix = suffix;
this.environment = logger;
}
@Override
public void finishClass(String fqn) throws IOException {
this.fqn = null;
}
}
SingleDualOutputStreamOutput.java 0000664 0000000 0000000 00000002620 15143236361 0034507 0 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs.log;
import java.io.PrintStream;
import java.io.PrintWriter;
public class SingleDualOutputStreamOutput extends DualOutputStreamOutput {
public SingleDualOutputStreamOutput(PrintWriter er) {
super(er, er);
}
public SingleDualOutputStreamOutput(PrintStream er) {
super(er, er);
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log/StderrLog.java 0000664 0000000 0000000 00000002326 15143236361 0030631 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs.log;
public class StderrLog extends SingleDualOutputStreamOutput {
public StderrLog() {
super(System.err);
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/outputs/log/StringLog.java 0000664 0000000 0000000 00000004337 15143236361 0030640 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2023, Oracle, Red Hat and/or theirs affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.outputs.log;
import org.openjdk.asmtools.common.outputs.ToolOutput;
public class StringLog extends NamedDualStreamToolOutput {
private final StringBuilder log = new StringBuilder();
@Override
public String toString() {
return log.toString();
}
@Override
public void printlns(String line) {
log.append(line).append(System.lineSeparator());
}
@Override
public void prints(String line) {
log.append(line);
}
@Override
public void prints(char line) {
log.append(line);
}
@Override
public void flush() {
}
@Override
public void printlne(String line) {
log.append(line).append(System.lineSeparator());
}
@Override
public void printe(String line) {
log.append(line);
}
@Override
public void printe(char line) {
log.append(line);
}
@Override
public void stacktrace(Throwable ex) {
log.append(ToolOutput.exToString(ex));
}
@Override
public ToolOutput getSToolObject() {
return this;
}
@Override
public ToolOutput getEToolObject() {
return this;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/ 0000775 0000000 0000000 00000000000 15143236361 0025612 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/CFVersion.java 0000664 0000000 0000000 00000020367 15143236361 0030323 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.structure;
import static org.openjdk.asmtools.common.structure.ClassFileContext.ORDINARY;
import static org.openjdk.asmtools.common.structure.ClassFileContext.VALUE_OBJECTS;
/*
* Class File Version
*/
public class CFVersion {
/**
* Default versions of class file
*/
public static final int DEFAULT_MAJOR_VERSION = 45;
public static final int DEFAULT_MINOR_VERSION = 3;
public static final int DEFAULT_MODULE_MAJOR_VERSION = 53;
public static final int DEFAULT_MODULE_MINOR_VERSION = 0;
public static final int UNDEFINED_VERSION = -1;
/* The version of a class file since which the compact format of stack map is necessary */
public static final int SPLIT_VERIFIER_CFV = 50;
// Vlahalla: Value Classes and Objects
public static final int VALUE_OBJECTS_MAJOR_VERSION = 69;
public static final int VALUE_OBJECTS_MINOR_VERSION = 65535;
private int major_version;
private int minor_version;
private int threshold_major_version;
private int threshold_minor_version;
private boolean frozen;
// Whether is the CVF set as a tool parameter -cv?
private boolean isSetByParameter;
public CFVersion() {
setVersion(UNDEFINED_VERSION, UNDEFINED_VERSION);
threshold_major_version = UNDEFINED_VERSION;
threshold_minor_version = UNDEFINED_VERSION;
EModifier.setGlobalContext(ORDINARY);
isSetByParameter = false;
frozen = false;
}
public CFVersion(CFVersion other) {
this.setVersion(other.major_version, other.minor_version);
threshold_major_version = other.threshold_major_version;
threshold_minor_version = other.threshold_minor_version;
this.isSetByParameter = other.isSetByParameter;
if (isValueObjectContext()) {
EModifier.setGlobalContext(VALUE_OBJECTS);
} else {
EModifier.setGlobalContext(ORDINARY);
}
this.frozen = other.frozen;
}
public CFVersion(int major_version, int minor_version) {
this.major_version = major_version;
this.minor_version = minor_version;
if (isValueObjectContext()) {
EModifier.setGlobalContext(VALUE_OBJECTS);
} else {
EModifier.setGlobalContext(ORDINARY);
}
}
public CFVersion setFrozen(boolean frozen) {
this.frozen = frozen;
return this;
}
public CFVersion setThreshold(int major_version, int minor_version) {
this.threshold_major_version = major_version;
this.threshold_minor_version = minor_version;
return this;
}
public CFVersion setVersion(int major_version, int minor_version) {
this.major_version = major_version;
this.minor_version = minor_version;
if (isValueObjectContext()) {
EModifier.setGlobalContext(VALUE_OBJECTS);
}
return this;
}
public CFVersion setFileVersion(int major_version, int minor_version) {
if (isSet() && isFrozen()) {
if (isThresholdSet()) {
if ((major_version < threshold_major_version) ||
(major_version == threshold_major_version && minor_version < threshold_minor_version)) {
return this;
}
} else {
return this;
}
}
return setVersion(major_version, minor_version);
}
public CFVersion setMajorVersion(int major_version) {
if (!frozen) {
setVersion(major_version, this.minor_version);
}
return this;
}
public CFVersion setMinorVersion(int minor_version) {
if (!frozen) {
setVersion(this.major_version, minor_version);
}
return this;
}
public CFVersion setByParameter(boolean parameter) {
isSetByParameter = parameter;
return this;
}
public boolean isSet() {
return major_version != UNDEFINED_VERSION && minor_version != UNDEFINED_VERSION;
}
public boolean isThresholdSet() {
return threshold_major_version != UNDEFINED_VERSION && threshold_minor_version != UNDEFINED_VERSION;
}
public boolean isSetByParameter() {
return this.isSetByParameter;
}
public boolean isFrozen() {
return frozen;
}
public String asString() {
return String.format("%s:%s", major_version == UNDEFINED_VERSION ? "(undef)" : major_version,
minor_version == UNDEFINED_VERSION ? "(undef)" : minor_version);
}
public String asThresholdString() {
return String.format("%s:%s-%s:%s",
threshold_major_version == UNDEFINED_VERSION ? "(undef)" : threshold_major_version,
threshold_minor_version == UNDEFINED_VERSION ? "(undef)" : threshold_minor_version,
major_version == UNDEFINED_VERSION ? "(undef)" : major_version,
minor_version == UNDEFINED_VERSION ? "(undef)" : minor_version
);
}
// A class file whose version number is 50.0 or above (§4.1) must be verified using the type checking rules given
// in the section 4.10.1. Verification by Type Checking
public boolean isTypeCheckingVerifier() {
return isSet() ? major_version >= SPLIT_VERIFIER_CFV : false;
}
public CFVersion initModuleDefaultVersion() {
if (!isSet()) {
setVersion(DEFAULT_MODULE_MAJOR_VERSION, DEFAULT_MODULE_MINOR_VERSION);
}
return this;
}
public CFVersion initClassDefaultVersion() {
if (!isSet()) {
if (EModifier.GlobalContext() == VALUE_OBJECTS) {
setVersion(VALUE_OBJECTS_MAJOR_VERSION, VALUE_OBJECTS_MINOR_VERSION);
} else {
setVersion(DEFAULT_MAJOR_VERSION, DEFAULT_MINOR_VERSION);
}
}
return this;
}
public static CFVersion copyOf(CFVersion cfv) {
CFVersion cfVersion = new CFVersion(cfv);
return cfVersion;
}
public int minor_version() {
return this.minor_version;
}
public int major_version() {
return this.major_version;
}
public boolean isValueObjectContext() {
return major_version > VALUE_OBJECTS_MAJOR_VERSION ||
(major_version == VALUE_OBJECTS_MAJOR_VERSION && minor_version == VALUE_OBJECTS_MINOR_VERSION);
}
public static boolean isValueObjectContext(int major_version, int minor_version) {
return major_version > VALUE_OBJECTS_MAJOR_VERSION ||
(major_version == VALUE_OBJECTS_MAJOR_VERSION && minor_version == VALUE_OBJECTS_MINOR_VERSION);
}
public static CFVersion ValueObjectsVersion() {
return new CFVersion(VALUE_OBJECTS_MAJOR_VERSION, VALUE_OBJECTS_MINOR_VERSION);
}
/**
* Returns true if the class file version only supports Synthetic attribute and doesn't support the ACC_SYNTHETIC flag
*
* When jasm processes files with classfile version <= 45, it shouldn't set the ACC_SYNTHETIC bit
* but add the Synthetic attribute instead. The ACC_SYNTHETIC bit wasn't introduced until classfile version 46.
*
* @return true if only Synthetic attribute is supported, false otherwise
*/
public boolean isSyntheticAttributeContext() {
return major_version <= 45;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/ClassFileContext.java 0000664 0000000 0000000 00000005027 15143236361 0031673 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.structure;
/**
* Class File context CF_Context enums
*/
public enum ClassFileContext {
NONE(0x0000, "n/a", false),
CLASS(0x0001, "class", false),
FIELD(0x0002, "field", false),
METHOD(0x0004, "method", false),
INNER_CLASS(0x0008, "inner-class", false),
MODULE(0x0010, "module", false),
REQUIRES(0x0020, "requires", false),
EXPORTS(0x0040, "exports", false),
OPENS(0x0080, "opens", false),
METHOD_PARAMETERS(0x0100, "method parameters", false),
MODULE_DIRECTIVES(0x0020 | 0x0040 | 0x0080, "module directives", false),
ORDINARY(0x0200, "ordinary", true),
VALUE_OBJECTS(0x0200, "value classes and objects", true);
private final int id;
private final String printVal;
private final boolean globalContext;
ClassFileContext(int id, String print, boolean globalContext) {
this.id = id;
this.printVal = print;
this.globalContext = globalContext;
}
public int getID() {
return id;
}
public String getName() {
return printVal;
}
public boolean isGlobal() {
return globalContext;
}
public boolean isOneOf(ClassFileContext... contexts) {
for (ClassFileContext cfc : contexts) {
if ((cfc.id & this.id) != 0) {
return true;
}
}
return false;
}
public boolean belongToContextOf(EModifier modifier) {
return (this.id & modifier.getAllovedContextMask()) != 0;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/EAttribute.java 0000664 0000000 0000000 00000016073 15143236361 0030534 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.structure;
import org.openjdk.asmtools.jasm.ClassFileConst;
import java.util.HashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openjdk.asmtools.jasm.ClassFileConst.ConstType.*;
/**
* 4.7. Attributes
*/
public enum EAttribute {
// Constant for JVMS
ATT_Unrecognized(-1, "ATT_Unrecognized", "", CONSTANT_UNKNOWN),
ATT_StackMap(1, "ATT_StackMap", "StackMap", CONSTANT_UNKNOWN),
// Numbers correspond to VM spec (chapter 4.7.X)
ATT_ConstantValue(2, "ATT_ConstantValue", "ConstantValue", CONSTANT_UTF8),
ATT_Code(3, "ATT_Code", "Code", CONSTANT_UNKNOWN),
ATT_StackMapTable(4, "ATT_StackMapTable", "StackMapTable", CONSTANT_UNKNOWN),
ATT_Exceptions(5, "ATT_Exceptions", "Exceptions", CONSTANT_UNKNOWN),
ATT_InnerClasses(6, "ATT_InnerClasses", "InnerClasses", CONSTANT_CLASS),
ATT_EnclosingMethod(7, "ATT_EnclosingMethod", "EnclosingMethod", CONSTANT_CLASS),
ATT_Synthetic(8, "ATT_Synthetic", "Synthetic", CONSTANT_UNKNOWN),
ATT_Signature(9, "ATT_Signature", "Signature", CONSTANT_UTF8),
ATT_SourceFile(10, "ATT_SourceFile", "SourceFile", CONSTANT_UTF8),
ATT_SourceDebugExtension(11, "ATT_SourceDebugExtension", "SourceDebugExtension", CONSTANT_UTF8),
ATT_LineNumberTable(12, "ATT_LineNumberTable", "LineNumberTable", CONSTANT_UNKNOWN),
ATT_LocalVariableTable(13, "ATT_LocalVariableTable", "LocalVariableTable", CONSTANT_UNKNOWN),
ATT_LocalVariableTypeTable(14, "ATT_LocalVariableTypeTable", "LocalVariableTypeTable", CONSTANT_UNKNOWN),
ATT_Deprecated(15, "ATT_Deprecated", "Deprecated", CONSTANT_UNKNOWN),
ATT_RuntimeVisibleAnnotations(16, "ATT_RuntimeVisibleAnnotations", "RuntimeVisibleAnnotations", CONSTANT_UNKNOWN),
ATT_RuntimeInvisibleAnnotations(17, "ATT_RuntimeInvisibleAnnotations", "RuntimeInvisibleAnnotations", CONSTANT_UNKNOWN),
ATT_RuntimeVisibleParameterAnnotations(18, "ATT_RuntimeVisibleParameterAnnotations", "RuntimeVisibleParameterAnnotations", CONSTANT_UNKNOWN),
ATT_RuntimeInvisibleParameterAnnotations(19, "ATT_RuntimeInvisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations", CONSTANT_UNKNOWN),
ATT_AnnotationDefault(20, "ATT_AnnotationDefault", "AnnotationDefault", CONSTANT_UNKNOWN),
ATT_BootstrapMethods(21, "ATT_BootstrapMethods", "BootstrapMethods", CONSTANT_METHODHANDLE),
ATT_RuntimeVisibleTypeAnnotations(22, "ATT_RuntimeVisibleTypeAnnotations", "RuntimeVisibleTypeAnnotations", CONSTANT_UNKNOWN),
ATT_RuntimeInvisibleTypeAnnotations(23, "ATT_RuntimeInvisibleTypeAnnotations", "RuntimeInvisibleTypeAnnotations", CONSTANT_UNKNOWN),
ATT_MethodParameters(24, "ATT_MethodParameters", "MethodParameters", CONSTANT_UTF8),
ATT_Module(25, "ATT_Module", "Module", CONSTANT_MODULE),
ATT_Version(26, "ATT_Version", "Version", CONSTANT_UTF8),
ATT_TargetPlatform(27, "ATT_TargetPlatform", "TargetPlatform", CONSTANT_UTF8),
ATT_MainClass(28, "ATT_MainClass", "MainClass", CONSTANT_CLASS),
ATT_ModulePackages(29, "ATT_ModulePackages", "ModulePackages", CONSTANT_PACKAGE),
ATT_ModuleMainClass(30, "ATT_ModuleMainClass", "ModuleMainClass", CONSTANT_CLASS),
// ATT_ModuleTarget(31, "ATT_ModuleTarget", "ModuleTarget", CONSTANT_UNKNOWN),
// JEP 181: class file 55.0
ATT_NestHost(32, "ATT_NestHost", "NestHost", CONSTANT_CLASS),
ATT_NestMembers(33, "ATT_NestMembers", "NestMembers", CONSTANT_CLASS),
// JEP 359 Record(Preview): class file 58.65535
// Record_attribute {
// u2 attribute_name_index;
// u4 attribute_length;
// u2 components_count;
// component_info components[components_count];
// }
ATT_Record(34, "ATT_Record", "Record", CONSTANT_UTF8),
// JEP 360 (Sealed types): class file 59.65535
// PermittedSubclasses_attribute {
// u2 attribute_name_index;
// u4 attribute_length;
// u2 number_of_classes;
// u2 classes[number_of_classes];
// }
ATT_PermittedSubclasses(35, "ATT_PermittedSubclasses", "PermittedSubclasses", CONSTANT_CLASS),
// Valhalla
ATT_LoadableDescriptors(36, "ATT_LoadableDescriptors", "LoadableDescriptors", CONSTANT_CLASS);
private final Integer value;
private final String printVal;
private final String parseKey;
private final ClassFileConst.ConstType constType;
private static HashMap parseKeyToTags;
private static HashMap valueToTags;
EAttribute(Integer value, String printValue, String parseKey, ClassFileConst.ConstType constType) {
this.value = value;
this.printVal = printValue;
this.parseKey = parseKey;
this.constType = constType;
}
public boolean isOneOf(EAttribute... attributes) {
for (EAttribute attribute : attributes) {
if (attribute == this) {
return true;
}
}
return false;
}
public String printValue() {
return printVal;
}
public String parseKey() {
return parseKey;
}
public ClassFileConst.ConstType getCPTypeOfIndex() {
return constType;
}
public int value() {
return value;
}
public static EAttribute get(int value) {
if (valueToTags == null) {
valueToTags = (HashMap) Stream.
of(EAttribute.values()).
collect(Collectors.toMap(EAttribute::value, Function.identity()));
}
EAttribute tg = valueToTags.get(value);
if (tg == null) {
tg = EAttribute.ATT_Unrecognized;
}
return tg;
}
public static EAttribute get(String parseKey) {
if (parseKeyToTags == null) {
parseKeyToTags = (HashMap) Stream.
of(EAttribute.values()).
collect(Collectors.toMap(EAttribute::parseKey, Function.identity()));
}
EAttribute tg = parseKeyToTags.get(parseKey);
if (tg == null) {
tg = EAttribute.ATT_Unrecognized;
}
return tg;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/ELocation.java 0000664 0000000 0000000 00000003114 15143236361 0030331 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.structure;
/**
* Attribute location
* Table 4.7-C. Predefined class file attributes (by location)
*/
public enum ELocation {
unknown("Unknown"),
class_file("ClassFile"),
field_info("field_info"),
method_info("method_info"),
record_component_info("record_component_info"),
code_atribute("Code");
public String getDescription() {
return description;
}
private final String description;
ELocation(String description) {
this.description = description;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/EModifier.java 0000664 0000000 0000000 00000047742 15143236361 0030336 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.structure;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import static org.openjdk.asmtools.common.structure.ClassFileContext.*;
/**
* 4. The class File Format
*
* The enum contains all JVMS (class, field, method, nested class, module and module statements) accesses and modifiers
* taken from tables 4.1-A, 4.1-B, 4.5-A, 4.6-A, 4.7.6-A, 4.7.25 etc according to their context @see EClassFileContext
*/
public enum EModifier {
ACC_NONE(0x0000, "", NONE), // <>
ACC_PUBLIC(0x0001, "public", CLASS, INNER_CLASS, FIELD, METHOD),
ACC_PRIVATE(0x0002, "private", INNER_CLASS, FIELD, METHOD),
ACC_PROTECTED(0x0004, "protected", INNER_CLASS, FIELD, METHOD),
ACC_STATIC(0x0008, "static", INNER_CLASS, FIELD, METHOD),
ACC_FINAL(0x0010, "final", CLASS, INNER_CLASS, FIELD, METHOD, METHOD_PARAMETERS),
ACC_SUPER(0x0020, "super", CLASS),
ACC_IDENTITY(0x0020, "identity", CLASS, INNER_CLASS, VALUE_OBJECTS), // Value Classes and Objects
ACC_VALUE(0x0000, "value", CLASS, INNER_CLASS, VALUE_OBJECTS), // Value Classes and Objects
ACC_TRANSITIVE(0x0020, "transitive", REQUIRES),
ACC_SYNCHRONIZED(0x0020, "synchronized", METHOD),
ACC_OPEN(0x0020, "open", MODULE),
ACC_VOLATILE(0x0040, "volatile", FIELD),
ACC_BRIDGE(0x0040, "bridge", METHOD),
ACC_STATIC_PHASE(0x0040, "static", REQUIRES),
ACC_TRANSIENT(0x0080, "transient", FIELD),
ACC_VARARGS(0x0080, "varargs", METHOD),
ACC_NATIVE(0x0100, "native", METHOD),
ACC_INTERFACE(0x0200, "interface", CLASS, INNER_CLASS),
ACC_ABSTRACT(0x0400, "abstract", CLASS, INNER_CLASS, METHOD),
ACC_STRICT(0x0800, "strict", METHOD, FIELD, VALUE_OBJECTS), // FIELD added for VALUE_OBJECTS CONTEXT
ACC_SYNTHETIC(0x1000, "synthetic", CLASS, INNER_CLASS, FIELD, METHOD, MODULE, REQUIRES, EXPORTS, OPENS, METHOD_PARAMETERS),
ACC_ANNOTATION(0x2000, "annotation", CLASS, INNER_CLASS),
ACC_ENUM(0x4000, "enum", CLASS, INNER_CLASS, FIELD),
ACC_MODULE(0x8000, "module", CLASS),
ACC_MANDATED(0x8000, "mandated", MODULE, REQUIRES, EXPORTS, OPENS, METHOD_PARAMETERS),
SYNTHETIC_ATTRIBUTE(0x00010000, "Synthetic(Pseudo)", CLASS, INNER_CLASS, FIELD, METHOD),
DEPRECATED_ATTRIBUTE(0x00020000, "Deprecated(Pseudo)", CLASS, INNER_CLASS, FIELD, METHOD),
VALUE_OBJECTS_ATTRIBUTE(0x010000000, "ValueObjects(Pseudo)", CLASS, INNER_CLASS, FIELD);
// Method access and property flags (Table 4.6-A)
public static final EModifier[] MM_METHOD = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
ACC_SYNCHRONIZED, ACC_BRIDGE, ACC_VARARGS, ACC_NATIVE, ACC_ABSTRACT,
ACC_SYNTHETIC,
ACC_STRICT }; // Valhalla SPECIFIC
// Class access and property modifiers (Table 4.1-A)
public static final EModifier[] MM_CLASS = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_FINAL,
ACC_SUPER, ACC_IDENTITY, ACC_INTERFACE,
ACC_ABSTRACT, ACC_SYNTHETIC,
ACC_ANNOTATION, ACC_ENUM, ACC_MODULE};
// Valid interface flags.
public static final EModifier[] MM_INTERFACE = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
ACC_INTERFACE,
ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION};
// Field access and property flags (Table 4.5-A)
public static final EModifier[] MM_FIELD = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT,
ACC_SYNTHETIC, ACC_ENUM,
ACC_STRICT}; // Valhalla SPECIFIC
// Abstract method
public static final EModifier[] MM_ABSTRACT_METHOD = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
ACC_BRIDGE, ACC_VARARGS, ACC_ABSTRACT,
ACC_SYNTHETIC};
// , method
public static final EModifier[] MM_INIT_METHOD = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
ACC_VARARGS, ACC_SYNTHETIC,
ACC_STRICT, ACC_STATIC};
// Nested class access and property flags (Table 4.7.6-A)
public static final EModifier[] MM_NESTED_CLASS = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
ACC_STATIC, ACC_FINAL,
ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM};
// Interface method
private static final EModifier[] MM_INTERFACE_METHOD = {ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED,
ACC_STATIC, ACC_BRIDGE, ACC_VARARGS,
ACC_ABSTRACT, ACC_STRICT, ACC_SYNTHETIC};
private static final EModifier[] MM_MODULE = {ACC_OPEN, ACC_SYNTHETIC, ACC_MANDATED};
private static final EModifier[] MM_MODULE_REQUIRES = {ACC_TRANSITIVE, ACC_STATIC_PHASE, ACC_SYNTHETIC, ACC_MANDATED};
private static final EModifier[] MM_MODULE_EXPORTS = {ACC_SYNTHETIC, ACC_MANDATED};
private static final EModifier[] MM_MODULE_OPENS = {ACC_SYNTHETIC, ACC_MANDATED};
// ToString converters
public static String NAMES_DELIMITER = ", ";
public static String NAMES_SUFFIX = "";
public static String KEYWORDS_DELIMITER = " ";
public static String KEYWORDS_SUFFIX = " ";
private final int flag;
private final String keyword;
private final Set contexts;
private int contextMask = 0;
// Externally changed switchers
private static ClassFileContext globalContext = ORDINARY;
EModifier(int flag, String keyword, ClassFileContext... contexts) {
this.flag = flag;
this.keyword = keyword;
this.contexts = new HashSet<>(10);
if (contexts != null) {
for (ClassFileContext c : contexts) {
this.contexts.add(c);
contextMask |= c.getID();
}
}
}
public static void setGlobalContext(ClassFileContext globalContext) {
EModifier.globalContext = globalContext;
}
public static ClassFileContext GlobalContext() {
return EModifier.globalContext;
}
// Wrappers
public static boolean isPublic(int flags) {
return (flags & ACC_PUBLIC.flag) != 0;
}
public static boolean isPrivate(int flags) {
return (flags & ACC_PRIVATE.flag) != 0;
}
public static boolean isProtected(int flags) {
return (flags & ACC_PROTECTED.flag) != 0;
}
public static boolean isStatic(int flags) {
return (flags & ACC_STATIC.flag) != 0;
}
public static boolean isFinal(int flags) {
return (flags & ACC_FINAL.flag) != 0;
}
public static boolean isTransitive(int flags) {
return isFinal(flags);
}
public static boolean isSuper(int flags) {
return (flags & ACC_SUPER.flag) != 0;
}
public static boolean isSynchronized(int flags) {
return isSuper(flags);
}
public static boolean isVolatile(int flags) {
return (flags & ACC_VOLATILE.flag) != 0;
}
public static boolean isBridge(int flags) {
return isVolatile(flags);
}
public static boolean isStaticPhase(int flags) {
return isVolatile(flags);
}
public static boolean isTransient(int flags) {
return (flags & ACC_TRANSIENT.flag) != 0;
}
public static boolean isVarArgs(int flags) {
return isTransient(flags);
}
public static boolean isNative(int flags) {
return (flags & ACC_NATIVE.flag) != 0;
}
public static boolean isInterface(int flags) {
return (flags & ACC_INTERFACE.flag) != 0;
}
public static boolean isAbstract(int flags) {
return (flags & ACC_ABSTRACT.flag) != 0;
}
public static boolean isStrict(int flags) {
return (flags & ACC_STRICT.flag) != 0;
}
public static int getNotPermitted(int flags, EModifier[] set) {
int notPermitted = 0;
for (EModifier mod : set) {
if ((flags & mod.flag) != 0) {
flags &= ~mod.flag;
ClassFileContext context = mod.getGlobalContext();
if( globalContext != context && context != ORDINARY) {
notPermitted |= mod.flag;
}
}
}
notPermitted |= flags;
return notPermitted;
}
public ClassFileContext getGlobalContext() {
for (ClassFileContext c : contexts) {
if (c.isGlobal()) {
return c;
}
}
return ORDINARY;
}
public static boolean isSynthetic(int flags) {
return (flags & ACC_SYNTHETIC.flag) != 0;
}
public static boolean isAnnotation(int flags) {
return (flags & ACC_ANNOTATION.flag) != 0;
}
public static boolean isEnum(int flags) {
return (flags & ACC_ENUM.flag) != 0;
}
public static boolean isModule(int flags) {
return (flags & ACC_MODULE.flag) != 0;
}
public static boolean isMandated(int flags) {
return isModule(flags);
}
public static boolean isSyntheticPseudoMod(int flags) {
return (flags & SYNTHETIC_ATTRIBUTE.flag) != 0;
}
public static boolean isDeprecatedPseudoMod(int flags) {
return (flags & DEPRECATED_ATTRIBUTE.flag) != 0;
}
// Value Classes and Objects
public static boolean isValueObjects(int flags) {
return (flags & VALUE_OBJECTS_ATTRIBUTE.flag) != 0;
}
public static boolean isIdentity(int flags) {
return (flags & ACC_IDENTITY.flag) != 0;
}
public static boolean hasPseudoMod(int flags) {
return isSyntheticPseudoMod(flags) || isDeprecatedPseudoMod(flags);
}
/*
* Check that only one flag is set
*/
public static boolean onlyOneOfFlags(int flag, EModifier... modifiers) {
if (modifiers.length >= 2) {
final int mask = flag & getFlags(modifiers);
return Arrays.stream(modifiers).mapToInt(EModifier::getFlag).anyMatch(f -> (f | mask) == f);
}
return modifiers.length != 0 && flag == modifiers[0].getFlag();
}
/*
* Check that at least one flag is set
*/
public static boolean anyOf(int flag, EModifier... modifiers) {
if (modifiers.length > 0) {
return (flag & getFlags(modifiers)) != 0;
}
return false;
}
public static int cleanFlags(int flag, EModifier... modifiers) {
if (modifiers.length > 0) {
for (EModifier m : modifiers) {
flag &= ~m.flag;
}
}
return flag;
}
/*
* Are both flags set?
*/
public static boolean both(int flags, EModifier modifierA, EModifier modifierB) {
final int bothFlags = modifierA.getFlag() | modifierB.getFlag();
return (flags & bothFlags) == bothFlags;
}
/*
* Is more than one flag set in the list?
*/
public static boolean moreThanOne(int flags, EModifier... modifiers) {
int count = 0;
for (EModifier m : modifiers) {
if( (flags & m.flag) != 0) {
count++;
}
}
return count > 1;
}
/*
* Check that there are no other modifiers in flags except given.
*/
public static boolean noFlagsExcept(int flags, EModifier... modifiers) {
return (flags & getFlags(modifiers)) == flags;
}
public static int getFlags(EModifier... modifiers) {
int flag = 0;
if (modifiers.length > 0) {
for (EModifier m : modifiers) {
flag |= m.flag;
}
}
return flag;
}
public static int getFlags(ClassFileContext context, EModifier... modifiers) {
int flag = 0;
if (modifiers.length == 0) {
modifiers = EModifier.values();
}
for (EModifier m : modifiers) {
if (m.contexts.contains(context)) {
flag |= m.flag;
}
}
return flag;
}
private static int addTo(ArrayList list, int flags, boolean isName, EModifier modifier) {
list.add(isName ? modifier.getFlagName() : modifier.getJavaFlagModifier());
return clearIfSet(flags, modifier);
}
public static String asKeywords(int modifiers, ClassFileContext context) {
return flagsToString(modifiers, false, context, KEYWORDS_DELIMITER, KEYWORDS_SUFFIX);
}
public static String asNames(int modifiers, ClassFileContext context) {
return flagsToString(modifiers, true, context, NAMES_DELIMITER, NAMES_SUFFIX);
}
private static String flagsToString(int modifiers, boolean isName, ClassFileContext context, String delimiter, String suffix) {
String s = String.join(delimiter, flagsToList(modifiers, isName, context));
return s.isBlank() ? "" : s + suffix;
}
/**
* Get either a keyword or a name of a flags according to the context.
*
* @param flags the flags to choose the corresponding names or keywords.
* @param isName either the JVMS modifier names or JLS keywords are selected
* @param context the entity for which the names/keywords are selected
* @return the List of the names or the keywords according to the parameter isName
*/
private static ArrayList flagsToList(int flags, boolean isName, ClassFileContext context) {
ArrayList list = new ArrayList<>();
// run through all access flags
if (isPublic(flags) && context.belongToContextOf(ACC_PUBLIC)) {
flags = addTo(list, flags, isName, ACC_PUBLIC);
}
if (isPrivate(flags) && context.belongToContextOf(ACC_PRIVATE)) {
flags = addTo(list, flags, isName, ACC_PRIVATE);
}
if (isProtected(flags) && context.belongToContextOf(ACC_PROTECTED)) {
flags = addTo(list, flags, isName, ACC_PROTECTED);
}
// ACC_STATIC
if (isStatic(flags) && context.belongToContextOf(ACC_STATIC)) {
// Static CLASS doesn't exist. Only INNER_CLASS, FIELD, METHOD can have this modifier.
flags = addTo(list, flags, isName, ACC_STATIC);
}
// ACC_FINAL
if (isFinal(flags) && context.isOneOf(CLASS, INNER_CLASS, FIELD, METHOD, METHOD_PARAMETERS)) {
flags = addTo(list, flags, isName, ACC_FINAL);
}
// ACC_TRANSITIVE ACC_SUPER ACC_SYNCHRONIZED ACC_OPEN
if (isSuper(flags)) { // == isTransitive(flags) == isSynchronized(flags) == isOpen(flags)
switch (context) {
case CLASS -> {
// In Java SE 8, the ACC_SUPER semantics became mandatory,
// regardless of the setting of ACC_SUPER or the class file version number,
// and the flags no longer had any effect.
// still we have to keep it in here (if it was here), as if the new class is used for hotswap, it s absence would casue
// java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class modifiers
flags = addTo(list, flags, isName, (globalContext == VALUE_OBJECTS) ? ACC_IDENTITY : ACC_SUPER);
}
case INNER_CLASS -> {
if(globalContext == VALUE_OBJECTS) {
flags = addTo(list, flags, isName, ACC_IDENTITY);
}
}
case REQUIRES -> flags = addTo(list, flags, isName, ACC_TRANSITIVE);
case METHOD -> flags = addTo(list, flags, isName, ACC_SYNCHRONIZED);
case MODULE -> flags = addTo(list, flags, isName, ACC_OPEN);
}
}
// ACC_VOLATILE ACC_BRIDGE ACC_STATIC_PHASE ACC_PERMITS_VALUE
if (isVolatile(flags)) { // == isBridge(flags) ==isStaticPhase(flags) == isPermitsValue(flags)
switch (context) {
case FIELD -> flags = addTo(list, flags, isName, ACC_VOLATILE);
case METHOD -> flags = addTo(list, flags, isName, ACC_BRIDGE);
case REQUIRES -> flags = addTo(list, flags, isName, ACC_STATIC_PHASE);
}
}
// ACC_TRANSIENT ACC_VARARGS
if (isTransient(flags)) { // == isVarArgs(flags)
switch (context) {
case FIELD -> flags = addTo(list, flags, isName, ACC_TRANSIENT);
case METHOD -> flags = addTo(list, flags, isName, ACC_VARARGS);
}
}
// ACC_NATIVE ACC_VALUE
if (isNative(flags)) { // == isValue(flags)
switch (context) {
case METHOD -> flags = addTo(list, flags, isName, ACC_NATIVE);
}
}
// ACC_INTERFACE
if (isInterface(flags) && context.isOneOf(CLASS, INNER_CLASS)) {
if (isName) {
flags = addTo(list, flags, true, ACC_INTERFACE);
} else {
flags = clearIfSet(flags, ACC_INTERFACE);
}
}
// ACC_ABSTRACT
if (isAbstract(flags) && context.isOneOf(CLASS, INNER_CLASS, METHOD)) {
flags = addTo(list, flags, isName, ACC_ABSTRACT);
}
// ACC_STRICT
if (isStrict(flags)) {
switch (context) {
case METHOD -> flags = addTo(list, flags, isName, ACC_STRICT);
case FIELD -> {
if (globalContext == VALUE_OBJECTS) {
flags = addTo(list, flags, isName, ACC_STRICT);
}
}
}
}
// ACC_SYNTHETIC
if (isSynthetic(flags) && context.belongToContextOf(ACC_SYNTHETIC)) {
flags = addTo(list, flags, isName, ACC_SYNTHETIC);
}
// ACC_ANNOTATION
if (isAnnotation(flags) && context.isOneOf(CLASS, INNER_CLASS)) {
flags = addTo(list, flags, isName, ACC_ANNOTATION);
}
// ACC_ENUM
if (isEnum(flags) && context.isOneOf(CLASS, INNER_CLASS, FIELD)) {
flags = addTo(list, flags, isName, ACC_ENUM);
}
// ACC_MODULE ACC_MANDATED
if (isModule(flags)) { // == isMandated(flags)
if (context == CLASS) {
if (isName) {
flags = addTo(list, flags, true, ACC_MODULE);
} else {
flags = clearIfSet(flags, ACC_MODULE);
}
} else if (context.isOneOf(MODULE, REQUIRES, EXPORTS, OPENS, METHOD_PARAMETERS)) {
flags = addTo(list, flags, isName, ACC_MANDATED);
}
}
if (flags != 0) {
list.add(String.format("0x%04X", flags));
}
return list;
}
private static int clearIfSet(int flag, EModifier... modifiers) {
for (EModifier m : modifiers) {
if ((flag & m.flag) != 0) {
flag &= ~m.flag;
}
}
return flag;
}
public Set getClassFileContext() {
return contexts;
}
public int getAllovedContextMask() {
return contextMask;
}
public int getFlag() {
return flag;
}
public String getJavaFlagModifier() {
return keyword;
}
public String getFlagName() {
return this.toString();
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/structure/StackMap.java 0000664 0000000 0000000 00000023445 15143236361 0030170 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common.structure;
import org.openjdk.asmtools.asmutils.FormatConsumer;
import org.openjdk.asmtools.asmutils.Range;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 4.7.4. The StackMapTable Attribute
*/
public class StackMap {
/**
* @param verificationTypeID u1 tag
* @param errorConsumer consumer to announce a problem
* @return associated StackMap Verification Type
*/
public static VerificationType getVerificationType(int verificationTypeID, Optional> errorConsumer) {
if (VerificationType.isValidVerificationType(verificationTypeID)) {
return VerificationType.get(verificationTypeID);
} else {
errorConsumer.ifPresent(c -> c.format("error.stackmap.unknown.type", verificationTypeID));
return VerificationType.ITEM_UNKNOWN;
}
}
public static VerificationType getVerificationType(String printName) {
return VerificationType.getByPrintName(printName);
}
/**
* Get Entry Type by tag belonging the range
*
* @param tag u1 tag in range
* @return
*/
public static EntryType stackMapEntryType(int tag) {
EntryType entryType;
entryType = EntryType.getByTag(tag);
return entryType;
}
/**
* Get frame type id by a name
*
* @param frameTypeName frame type name
* @return Stack FrameType tag [0..255]
*/
public static int getFrameTypeTagByName(String frameTypeName) {
return EntryType.getByTagName(frameTypeName).fromTag();
}
/**
* Get entry type id by a name
*
* @param entryTypeName entry type name
* @return Stack FrameType tag [0..255]
*/
public static EntryType getEntryTypeByName(String entryTypeName) {
return EntryType.getByTagName(entryTypeName);
}
/**
* Checks if the tag belongs to range of valid Frame Types
*
* @param tag
* @return true if the tag does not belong to a range either of UNKNOWN_TYPE or RESERVED
*/
public static boolean isValidEntryType(int tag) {
return EntryType.isValid(tag);
}
/**
* MapTypes table. These constants are used in stackmap pseudo-instructions only.
*/
public enum VerificationType {
/* Type codes for StackMap attribute */
ITEM_UNKNOWN(-1, "??? Unknown verification type", "UNKNOWN"), // placeholder for wrong types
ITEM_Bogus(0, "bogus", "B"), // an unknown or uninitialized value
ITEM_Integer(1, "int", "I"), // a 32-bit integer
ITEM_Float(2, "float", "F"), // not used
ITEM_Double(3, "double", "D"), // not used
ITEM_Long(4, "long", "L"), // a 64-bit integer
ITEM_Null(5, "null", "N"), // the type of null
ITEM_InitObject(6, "this", "IO"), // "this" in constructor
ITEM_Object(7, "CP", "O"), // followed by 2-byte index of class name
ITEM_NewObject(8, "at", "NO"); // followed by 2-byte ref to "new"
private static HashMap printNameToType;
private static HashMap parseKeyToType;
private static HashMap tagToType;
private final String printName;
private final String parseKey;
private Integer tag;
VerificationType(Integer tag, String printName, String parseKey) {
this.tag = tag;
this.printName = printName;
this.parseKey = parseKey;
}
static boolean isValidVerificationType(int tag) {
return tag >= ITEM_Bogus.tag && tag <= ITEM_NewObject.tag;
}
public static VerificationType getByPrintName(String printName) {
if (printNameToType == null) {
printNameToType = (HashMap) Arrays.stream(VerificationType.values()).
collect(Collectors.toMap(VerificationType::printName, Function.identity()));
}
return printNameToType.get(printName);
}
public static VerificationType getByParseKey(String parseKey) {
if (parseKeyToType == null) {
parseKeyToType = (HashMap) Arrays.stream(VerificationType.values()).
collect(Collectors.toMap(VerificationType::parseKey, Function.identity()));
}
VerificationType verificationType = parseKeyToType.get(parseKey);
return verificationType == null ? VerificationType.ITEM_UNKNOWN : verificationType;
}
public static VerificationType get(int tag) {
if (tagToType == null) {
tagToType = (HashMap) Arrays.stream(VerificationType.values()).
collect(Collectors.toMap(VerificationType::tag, Function.identity()));
}
return tagToType.get(tag);
}
public String parseKey() {
return this.parseKey;
}
public String printName() {
return this.printName;
}
public Integer tag() {
return this.tag;
}
}
/**
* StackMap-FrameType table. These constants are used in stackmap pseudo-instructions
* only.
*/
public enum EntryType {
UNKNOWN_TYPE(-1, -1, "unknown", false, false, false), // placeholder for wrong frame types
/* Type codes for StackMapFrame attribute */
SAME_FRAME(0, 63, "same", false, false, false),
SAME_LOCALS_1_STACK_ITEM_FRAME(64, 127, "stack1", false, true, false),
RESERVED(128, 245, "reserved", false, false, false),
EARLY_LARVAL(246, 246, "early_larval", false, false, true),
SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED(247, 247, "stack1_ex", false, true, false),
CHOP_1_FRAME(250, 250, "chop1", false, false, false),
CHOP_2_FRAME(249, 249, "chop2", false, false, false),
CHOP_3_FRAME(248, 248, "chop3", false, false, false),
SAME_FRAME_EXTENDED(251, 251, "same_ex", false, false, false),
APPEND_FRAME(252, 254, "append", true, false, false),
FULL_FRAME(255, 255, "full", true, true, false);
private static HashMap tagNameToFrameType;
private final Range tagRange;
private final String tagName;
private final boolean localMap;
private final boolean stackMap;
private final boolean fields;
EntryType(int from, int to, String tagName, boolean localMap, boolean stackMap, boolean fields) {
this.tagRange = new Range<>(from, to);
this.tagName = tagName;
this.localMap = localMap;
this.stackMap = stackMap;
this.fields = fields;
}
public boolean hasLocalMap() {
return localMap;
}
public boolean hasStackMap() {
return stackMap;
}
public boolean hasFields() {
return fields;
}
public static EntryType getByTagName(String tagName) {
if (tagNameToFrameType == null) {
tagNameToFrameType = (HashMap) Arrays.stream(EntryType.values()).
collect(Collectors.toMap(EntryType::tagName, Function.identity()));
}
EntryType type = tagNameToFrameType.get(tagName);
return type == null ? EntryType.UNKNOWN_TYPE : type;
}
public static EntryType getByTag(int tag) {
for (EntryType type : EntryType.values()) {
if (type.inRange(tag)) {
return type;
}
}
return EntryType.UNKNOWN_TYPE;
}
public int fromTag() {
return tagRange.from();
}
public String tagName() {
return tagName;
}
public String printName() {
String buf = this.name().toLowerCase().replace("_frame", "");
return buf.startsWith("chop") ? tagName : buf;
}
public boolean inRange(int tag) {
return tagRange.in(tag);
}
/**
* Checks if the tag belongs to range of valid Frame Types
*
* @param tag
* @return true if the tag does not belong to a range either of UNKNOWN_TYPE or RESERVED
*/
public static boolean isValid(int tag) {
for (EntryType entryType : Set.of(UNKNOWN_TYPE, RESERVED)) {
if (entryType.inRange(tag))
return false;
}
return true;
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/common/uEscWriter.java 0000664 0000000 0000000 00000003500 15143236361 0026507 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.common;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
public class uEscWriter extends Writer {
static final char[] hexTable = "0123456789ABCDEF".toCharArray();
OutputStream out;
byte[] tmpl;
public uEscWriter(OutputStream out) {
this.out = out;
tmpl = new byte[6];
tmpl[0] = (byte) '\\';
tmpl[1] = (byte) 'u';
}
@Override
public synchronized void write(char[] cc, int ofs, int len) throws IOException {
byte[] b = String.copyValueOf(cc, ofs, len).getBytes(StandardCharsets.UTF_8);
out.write(b, ofs, b.length);
}
@Override
public void flush() {
}
@Override
public void close() {
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/i18n.properties 0000664 0000000 0000000 00000004652 15143236361 0025166 0 ustar 00root root 0000000 0000000 # Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
main.usage=\
Usage: java -jar {0} run jasm, jdis, jcoder, or jdec tool\n\
\ or: java -jar {0} -?|-h|-help print Help (this message) and exit\n\
\ or: java -jar {0} -version print version information and exit\n\
use -dls switch to return the ancient dual stream logging\n
main.error.no_arguments=No arguments provided! See options above.
main.error.unknown_tool=Tool name \"{0}\" unrecognized. See the usage above for possible tool choices.
# shared strings
err.does_not_exist=The output directory \"{0}\" does not exist
err.d_requires_argument=-d requires argument
err.f_requires_argument=-f requires argument
info.opt.d=\
\ -d Specify where to place generated class files, otherwise
info.opt.w=\
\ -w Specify where to place generated class files, without considering the classpath, otherwise
info.opt.v=\
\ -v Print additional information
info.opt.t=\
\ -t Print debug, trace information
info.opt.version=\
\ -version Print the program version
main.error.wrong.utf8=The bytes do not represent a valid modified UTF-8 encoding of a Unicode string.
main.error.wrong.bytes=Corrupted class file. The bytes do not represent a valid class attribute.
error.stackmap.unknown.type=Unknown StackMapTable verification type {0}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/ 0000775 0000000 0000000 00000000000 15143236361 0023214 5 ustar 00root root 0000000 0000000 jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/AnnotationData.java 0000664 0000000 0000000 00000006410 15143236361 0026764 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import java.io.IOException;
import java.util.ArrayList;
import java.util.stream.IntStream;
/**
* JVMS 4.7.16.
*
* annotation {
* u2 type_index;
* u2 num_element_value_pairs;
* { u2 element_name_index;
* element_value value;
* } element_value_pairs[num_element_value_pairs];
* }
*/
class AnnotationData implements ConstantPoolDataVisitor {
boolean invisible;
Indexer typeCPX;
ArrayList elemValuePairs;
@Override
public T visit(ConstantPool pool) {
for( ElemValuePair pair : elemValuePairs ) {
pair.visit(pool);
}
return (T) this;
}
/**
* AnnotationElemValue
*
* Used to store Annotation Data
*/
static public class ElemValuePair implements ConstantPoolDataVisitor {
ConstCell name;
DataWriter value;
public ElemValuePair(ConstCell name, DataWriter value) {
this.name = name;
this.value = value;
}
@Override
public void write(CheckedDataOutputStream out) throws IOException {
name.write(out);
value.write(out);
}
@Override
public int getLength() {
return 2 + value.getLength();
}
@Override
public T visit(ConstantPool pool) {
this.name = visitConstCell(this.name, pool);
this.value = visitData(this.value, pool);
return (T) this;
}
}
public AnnotationData(Indexer typeCPX, boolean invisible) {
this.typeCPX = typeCPX;
this.elemValuePairs = new ArrayList<>();
this.invisible = invisible;
}
public void add(ElemValuePair elemValuePair) {
elemValuePairs.add(elemValuePair);
}
@Override
public void write(CheckedDataOutputStream out) throws IOException {
out.writeShort(typeCPX.cpIndex);
out.writeShort(elemValuePairs.size());
for (DataWriter pair : elemValuePairs) {
pair.write(out);
}
}
@Override
public int getLength() {
return 4 + elemValuePairs.stream().flatMapToInt(elem-> IntStream.of(elem.getLength())).sum();
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/ArrayAttr.java 0000664 0000000 0000000 00000005200 15143236361 0025765 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import org.openjdk.asmtools.common.structure.EAttribute;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Base class of the "classes/descriptors[]" data of attributes
*
* JEP 181 (Nest-based Access Control): class file 55.0
* NestMembers_attribute {
* u2 attribute_name_index;
* u4 attribute_length;
* u2 number_of_classes;
* u2 classes[number_of_classes];
* }
*
* JEP 360 (Sealed types): class file 59.65535
* PermittedSubclasses_attribute {
* u2 attribute_name_index;
* u4 attribute_length;
* u2 number_of_classes;
* u2 classes[number_of_classes];
* }
*
* Valhalla:
* LoadableDescriptors_attribute {
* u2 attribute_name_index;
* u4 attribute_length;
* u2 number_of_descriptors;
* u2 descriptors[number_of_descriptors];
* }
*/
public class ArrayAttr extends AttrData {
List cells = new ArrayList<>();
public ArrayAttr(ConstantPool pool, EAttribute attribute, List constCellList) {
super(pool, attribute);
for (ConstCell> cell : constCellList) {
this.cells.add(classifyConstCell(pool, cell));
}
}
public int size() {
return cells.size();
}
@Override
public int attrLength() {
return 2 + cells.size() * 2;
}
@Override
public void write(CheckedDataOutputStream out) throws IOException {
super.write(out);
out.writeShort(cells.size());
for (ConstCell c : cells) {
out.writeShort(c.cpIndex);
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/AttrData.java 0000664 0000000 0000000 00000010343 15143236361 0025564 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import org.openjdk.asmtools.common.structure.EAttribute;
import java.io.IOException;
import java.util.Optional;
import static org.openjdk.asmtools.jasm.ClassFileConst.ConstType.*;
/**
* AttrData
*
* AttrData is the base class for many attributes (or parts of attributes), and it is
* instantiated directly for simple attributes (like Synthetic or Deprecated).
*/
class AttrData implements ConstantPoolDataVisitor {
private final EAttribute attribute;
private final ConstCell attributeNameConstantCell;
AttrData(ConstantPool pool, EAttribute attribute) {
this.attribute = attribute;
this.attributeNameConstantCell = pool.findUTF8Cell(attribute.parseKey());
}
@Override
public T visit(ConstantPool pool) {
if (this instanceof CPXAttr cpxAttr) {
final ConstCell cell = cpxAttr.cell;
if (! cell.isSet()) {
if (cell.getType() == CONSTANT_STRING) {
if (attribute.getCPTypeOfIndex() == CONSTANT_UTF8) {
Optional> strCell = pool.ConstantPoolHashByValue.values().stream().
filter(v -> v.isSet() && v.getType() == CONSTANT_STRING && v.equalsByValue(cell)).
findFirst();
cpxAttr.cell = strCell.isPresent() ?
strCell.get() :
pool.findCell(new ConstantPool.ConstValue_String((ConstCell) cell.ref.value));
}
}
}
}
return (T) this;
}
protected ConstCell> classifyConstCell(ConstantPool pool, ConstCell> cell) {
switch (cell.getType()) {
case CONSTANT_CLASS -> {
return cell;
}
case CONSTANT_UTF8 -> {
if( attribute.getCPTypeOfIndex() == CONSTANT_CLASS ) {
Optional> clsCell = pool.ConstantPoolHashByValue.values().stream().
filter(v -> v.getType() == CONSTANT_CLASS && v.ref.value.equals(cell)).
findAny();
if (clsCell.isPresent()) {
return clsCell.get();
} else {
// create class cell referencing to UTF8
return pool.findCell(new ConstantPool.ConstValue_Class((ConstCell) cell));
}
}
}
default -> {
// no action
}
}
return cell;
}
// full length of the attribute
// declared in Data
@Override
public int getLength() {
return 6 + attrLength();
}
// subclasses must redefine this
public int attrLength() {
return 0;
}
@Override
public void write(CheckedDataOutputStream out) throws IOException {
out.writeShort(attributeNameConstantCell.cpIndex);
out.writeInt(attrLength()); // attribute length
}
public EAttribute getAttribute() {
return attribute;
}
} // end class AttrData
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/BootstrapMethodData.java 0000664 0000000 0000000 00000010541 15143236361 0027770 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
class BootstrapMethodData extends Indexer implements DataWriter {
ConstCell bootstrapMethodHandle;
List> arguments;
public BootstrapMethodData(ConstCell bsmHandle, List> arguments) {
super();
this.bootstrapMethodHandle = bsmHandle;
this.arguments = arguments;
}
// methodAttrIndex - bootstrap_method_attr_index
// The value of the bootstrap_method_attr_index item must be a valid index into the bootstrap_methods array
// of the bootstrap method table of this class file (§4.7.23).
public BootstrapMethodData(int methodAttrIndex) {
super();
this.bootstrapMethodHandle = null;
this.arguments = new ArrayList<>();
super.cpIndex = methodAttrIndex;
}
public int getLength() {
return 4 + arguments.size() * 2;
}
public boolean hasMethodAttrIndex() {
return super.isSet();
}
public void setMethodAttrIndex(int methodAttrIndex) {
super.cpIndex = methodAttrIndex;
}
public int getMethodAttrIndex() {
return super.cpIndex;
}
public void write(CheckedDataOutputStream out) throws IOException {
out.writeShort(bootstrapMethodHandle.cpIndex);
out.writeShort(arguments.size());
for (ConstCell argument : arguments) {
out.writeShort(argument.cpIndex);
}
}
@Override
public String toString() {
return String.format("{MethodHandle:%s Arguments:%s}",
bootstrapMethodHandle == null || bootstrapMethodHandle.cpIndex == NotSet ? " n/a" : " #" + bootstrapMethodHandle.cpIndex,
arguments == null || arguments.isEmpty() ? "{}" :
"{ " + arguments.stream().map(a -> String.format("#%d", a.cpIndex)).collect(Collectors.joining(", ")) + " }");
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BootstrapMethodData)) return false;
BootstrapMethodData that = (BootstrapMethodData) o;
if (!Objects.equals(bootstrapMethodHandle, that.bootstrapMethodHandle))
return false;
return this.cpIndex == that.cpIndex & Objects.equals(arguments, that.arguments);
}
@Override
public int hashCode() {
int result = 31 * (bootstrapMethodHandle != null ? bootstrapMethodHandle.hashCode() : 0);
result = 31 * result + (arguments != null ? arguments.hashCode() : 0);
return result;
}
public boolean equalsByValue(Object o) {
if (this == o) return true;
if (!(o instanceof BootstrapMethodData)) return false;
BootstrapMethodData that = (BootstrapMethodData) o;
if (!Objects.equals(bootstrapMethodHandle, that.bootstrapMethodHandle))
return false;
if (arguments == that.arguments) return true;
if (arguments != null && (arguments.size() == that.arguments.size())) {
for (int i = 0; i < arguments.size(); i++) {
if (!arguments.get(i).equalsByValue(that.arguments.get(i))) {
return false;
}
}
return true;
}
return false;
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/CPTagVisitor.java 0000664 0000000 0000000 00000010570 15143236361 0026400 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import org.openjdk.asmtools.common.CompilerConstants;
import static java.lang.String.format;
/**
* Constant Pool Tag Visitor base class defining a visitor for decoding constants.
*/
public abstract class CPTagVisitor implements CompilerConstants {
public CPTagVisitor() { }
public final R visit(ClassFileConst.ConstType tag) {
switch (tag) {
case CONSTANT_UTF8, CONSTANT_ASCIZ -> {
return visitUTF8();
}
case CONSTANT_INTEGER, CONSTANT_INT,
CONSTANT_BYTE, CONSTANT_C_BYTE,
CONSTANT_CHAR, CONSTANT_C_CHAR,
CONSTANT_SHORT, CONSTANT_C_SHORT,
CONSTANT_C_BOOLEAN, CONSTANT_BOOLEAN -> {
return visitInteger(tag);
}
case CONSTANT_FLOAT, CONSTANT_C_FLOAT -> {
return visitFloat();
}
case CONSTANT_DOUBLE, CONSTANT_C_DOUBLE -> {
return visitDouble();
}
case CONSTANT_LONG, CONSTANT_C_LONG -> {
return visitLong();
}
case CONSTANT_METHODTYPE -> {
return visitMethodType();
}
case CONSTANT_STRING, CONSTANT_L_STRING -> {
return visitString();
}
case CONSTANT_CLASS, CONSTANT_C_CLASS -> {
return visitClass();
}
case CONSTANT_METHODREF, CONSTANT_METHOD -> {
return visitMethod();
}
case CONSTANT_FIELDREF, CONSTANT_FIELD -> {
return visitField();
}
case CONSTANT_INTERFACEMETHODREF, CONSTANT_INTERFACEMETHOD -> {
return visitInterfaceMethod();
}
case CONSTANT_NAMEANDTYPE -> {
return visitNameAndType();
}
case CONSTANT_METHODHANDLE -> {
return visitMethodHandle();
}
case CONSTANT_DYNAMIC -> {
return visitDynamic();
}
case CONSTANT_INVOKEDYNAMIC -> {
return visitInvokeDynamic();
}
case CONSTANT_PACKAGE -> {
return visitPackage();
}
case CONSTANT_MODULE -> {
return visitModule();
}
}
throw new RuntimeException(
format("The Constant Type \"%s\" does not have a corresponding visitor function.", tag.printVal()));
}
public abstract R visitUTF8();
// The following types are allowed: CONSTANT_INTEGER, CONSTANT_INTEGER_BYTE,
// CONSTANT_INTEGER_CHAR, CONSTANT_INTEGER_SHORT, CONSTANT_INTEGER_BOOLEAN
public abstract R visitInteger(ClassFileConst.ConstType tag);
public abstract R visitFloat();
public abstract R visitDouble();
public abstract R visitLong();
public abstract R visitMethodType();
public abstract R visitString();
public abstract R visitClass();
public abstract R visitMethod();
public abstract R visitField();
public abstract R visitInterfaceMethod();
public abstract R visitNameAndType();
public abstract R visitMethodHandle();
public abstract R visitDynamic();
public abstract R visitInvokeDynamic();
public abstract R visitModule();
public abstract R visitPackage();
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/CPVisitor.java 0000664 0000000 0000000 00000005515 15143236361 0025747 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
/**
* CPVisitor base class defining a visitor for decoding constants.
*/
public interface CPVisitor< C extends ConstantPool.ConstValue_Cell, P extends ConstantPool.ConstValue_Pair> {
default void visit(ConstValue constValue) {
switch (constValue.tag) {
case CONSTANT_ZERO:
break; // ignore
case CONSTANT_METHODTYPE,
CONSTANT_STRING, CONSTANT_L_STRING,
CONSTANT_CLASS, CONSTANT_C_CLASS,
CONSTANT_MODULE, CONSTANT_PACKAGE:
visitConstValueCell((C) constValue);
break;
case CONSTANT_METHODREF, CONSTANT_METHOD,
CONSTANT_FIELDREF, CONSTANT_FIELD,
CONSTANT_INTERFACEMETHODREF, CONSTANT_INTERFACEMETHOD,
CONSTANT_NAMEANDTYPE:
visitConstValueRefCell((P) constValue);
break;
case CONSTANT_METHODHANDLE:
visitMethodHandle((ConstantPool.ConstValue_MethodHandle) constValue);
break;
case CONSTANT_UTF8, CONSTANT_ASCIZ,
CONSTANT_INTEGER, CONSTANT_INT,
CONSTANT_BYTE, CONSTANT_C_BYTE,
CONSTANT_CHAR, CONSTANT_C_CHAR,
CONSTANT_SHORT, CONSTANT_C_SHORT,
CONSTANT_C_BOOLEAN, CONSTANT_BOOLEAN,
CONSTANT_FLOAT, CONSTANT_C_FLOAT,
CONSTANT_DOUBLE, CONSTANT_C_DOUBLE,
CONSTANT_LONG, CONSTANT_C_LONG,
CONSTANT_DYNAMIC, CONSTANT_INVOKEDYNAMIC:
// default
default:
}
}
void visitConstValueCell(C constValue);
void visitConstValueRefCell(P constValue);
void visitMethodHandle(ConstantPool.ConstValue_MethodHandle constValue);
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/CPXAttr.java 0000664 0000000 0000000 00000003236 15143236361 0025350 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import org.openjdk.asmtools.common.structure.EAttribute;
import java.io.IOException;
/**
* Constant Pool Index Attribute
*/
class CPXAttr extends AttrData {
ConstCell> cell;
public CPXAttr(ConstantPool pool, EAttribute attribute, ConstCell> cell) {
super(pool, attribute);
this.cell = classifyConstCell(pool, cell);
}
public int attrLength() {
return 2;
}
public void write(CheckedDataOutputStream out) throws IOException {
super.write(out); // attr name, attr len
out.writeShort(cell.cpIndex);
}
} // end class CPXAttr
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/CheckedDataOutputStream.java 0000664 0000000 0000000 00000003564 15143236361 0030604 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import java.io.IOException;
public interface CheckedDataOutputStream {
void write(int b) throws IOException;
void write(byte b[], int off, int len) throws IOException;
default void write(byte b[]) throws IOException {
write(b,0, b.length);
}
void writeBoolean(boolean v) throws IOException;
void writeByte(int v) throws IOException;
void writeShort(int v) throws IOException;
void writeChar(int v) throws IOException;
void writeInt(int v) throws IOException;
void writeLong(long v) throws IOException;
void writeFloat(float v) throws IOException;
void writeDouble(double v) throws IOException;
void writeBytes(String s) throws IOException;
void writeChars(String s) throws IOException;
void writeUTF(String s) throws IOException;
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/Checker.java 0000664 0000000 0000000 00000035367 15143236361 0025441 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import org.openjdk.asmtools.common.structure.ClassFileContext;
import org.openjdk.asmtools.common.structure.EModifier;
import static org.openjdk.asmtools.common.structure.EModifier.*;
import static org.openjdk.asmtools.jasm.JasmTokens.Token;
/**
* Utility methods to verify modifiers masks for classes, interfaces, methods and fields
*/
public class Checker {
private Checker() {
}
/*
* Check that only one of the Access flags is set.
*/
private static boolean validAccess(int mod) {
return EModifier.onlyOneOfFlags(mod, ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED);
}
public static boolean validNestedClass(int flags) {
return (flags & ~getFlags(MM_NESTED_CLASS)) == 0;
}
public static boolean validField(int flags) {
return (flags & ~getFlags(MM_FIELD)) == 0;
}
public static int notValidField(int flags) {
return getNotPermitted(flags, MM_FIELD);
}
/*
* Methods of classes may have any of the flags in Table 4.6-A set. (MM_METHOD)
* However, each method of a class may have at most one of its ACC_PUBLIC, ACC_PRIVATE, and ACC_PROTECTED flags set (JLS §8.4.3).
*/
private static boolean validMethod(int mod) {
return noFlagsExcept(mod, MM_METHOD);
}
public static boolean validAbstractMethod(int flags) {
return (flags & ~getFlags(MM_ABSTRACT_METHOD)) == 0;
}
public static boolean validInitMethod(int flags) {
return (flags & ~getFlags(MM_INIT_METHOD)) == 0;
}
/*
* Fields of interfaces must have their ACC_PUBLIC, ACC_STATIC, and ACC_FINAL flags set;
* they may have their ACC_SYNTHETIC flag set and must not have any of the other flags in Table 4.5-A set (JLS §9.3).
*/
public static boolean validInterfaceField(int mod) {
int flags = isSynthetic(mod) ? mod & ~ACC_SYNTHETIC.getFlag() : mod;
flags = isStrict(flags) ? flags & ~ACC_STRICT.getFlag() : flags;
return noFlagsExcept(flags, ACC_PUBLIC, ACC_STATIC, ACC_FINAL);
}
/**
* The only flags are allowed in interface: ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION
*/
public static boolean validInterface(int mod) {
return noFlagsExcept(mod, MM_INTERFACE);
}
/*
* The only flags allowed to the Class are set.
*/
public static boolean validClass(int mod) {
return noFlagsExcept(mod, MM_CLASS);
}
public static boolean isValueObjectsContext() {
return EModifier.GlobalContext() == ClassFileContext.VALUE_OBJECTS;
}
/**
* Check the modifier flags for the class
*
* @param mod The modifier flags being checked
* @param scanner The file parser
*/
public static void checkClassModifiers(int mod, Scanner scanner) {
// Check "Value Classes and Objects" Context
if (EModifier.isValueObjects(mod)) {
EModifier.setGlobalContext(ClassFileContext.VALUE_OBJECTS);
}
mod = EModifier.cleanFlags(mod, DEPRECATED_ATTRIBUTE, SYNTHETIC_ATTRIBUTE, VALUE_OBJECTS_ATTRIBUTE);
// check Ambiguous use of similar modifiers
if (EModifier.moreThanOne(mod, ACC_PUBLIC, ACC_PROTECTED, ACC_PRIVATE)) {
scanner.environment.warning(scanner.pos, "warn.repeated.modifier");
}
if (scanner.token != Token.CLASS && !EModifier.isInterface(mod)) {
scanner.environment.warning(scanner.pos, "warn.one.of.two.token.expected",
Token.CLASS.parseKey(), Token.INTERFACE.parseKey(), Token.CLASS.parseKey());
}
// Interface
if (isInterface(mod)) {
// If the ACC_INTERFACE flag is set, the ACC_ABSTRACT flag must also be set.
if (!isAbstract(mod)) {
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.int.abs",
EModifier.asNames(mod, ClassFileContext.CLASS));
}
// If the ACC_INTERFACE flag is set, the ACC_FINAL, ACC_IDENTITY, ACC_ENUM, and ACC_MODULE flags must not be set.
if (anyOf(mod, ACC_FINAL, ACC_ENUM, ACC_IDENTITY, ACC_MODULE)) {
if (isValueObjectsContext()) {
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.interface.set.vo",
EModifier.asNames(mod, ClassFileContext.CLASS));
} else {
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.interface.set",
EModifier.asNames(mod, ClassFileContext.CLASS));
}
}
// Class
} else {
// If the ACC_INTERFACE flag is not set, any of the other flags in Table 4.1-B may be set except ACC_ANNOTATION and ACC_MODULE.
if (anyOf(mod, ACC_ANNOTATION, ACC_MODULE)) {
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.not.interface.set",
EModifier.asNames(mod, ClassFileContext.CLASS));
}
if (isValueObjectsContext()) {
// However, such a class file must have at least one of its ACC_FINAL, ACC_IDENTITY, or ACC_ABSTRACT flags set,
if (!anyOf(mod, ACC_FINAL, ACC_IDENTITY, ACC_ABSTRACT)) {
String buf = EModifier.asNames(mod, ClassFileContext.CLASS);
buf = (buf.isEmpty() ? "ACC_VALUE" : "ACC_VALUE, ".concat(buf));
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.not.interface.set.vo", buf);
}
}
if (!validClass(mod)) {
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.class",
EModifier.asNames(mod & ~getFlags(MM_CLASS), ClassFileContext.CLASS));
}
}
// Must not have both its ACC_FINAL and ACC_ABSTRACT flags set (JLS §8.1.1.2).
if (both(mod, ACC_ABSTRACT, ACC_FINAL)) {
scanner.environment.warning(scanner.pos, "warn.invalid.modifier.class.finabs",
EModifier.asNames(mod, ClassFileContext.CLASS));
}
}
/**
* Check the modifier flags for the field
*
* @param classData The ClassData for the current class
* @param mod The modifier flags being checked
* @param pos the position of the parser in the file
*/
public static void checkFieldModifiers(ClassData classData, int mod, long pos) {
JasmEnvironment environment = classData.getEnvironment();
mod = EModifier.cleanFlags(mod, DEPRECATED_ATTRIBUTE, SYNTHETIC_ATTRIBUTE);
if (classData.isInterface()) { // For interfaces fields.
// Fields of interfaces must have their ACC_PUBLIC, ACC_STATIC, and ACC_FINAL flags set;
//they may have their ACC_STRICT_INIT or ACC_SYNTHETIC flag set, and must not have any of the other flags in Table 4.5-A set (JLS §9.3).
if (!validInterfaceField(mod)) {
environment.warning(pos, "warn.invalid.modifier.intfield",
EModifier.asNames(mod, ClassFileContext.FIELD));
}
//
if( !isPublic(mod)) {
environment.warning(pos, "warn.invalid.modifier.intfield",
EModifier.asNames(mod, ClassFileContext.FIELD));
}
} else { // For non-interface fields.
if (isValueObjectsContext()) {
// Each field of a value class must have at least one of its ACC_STATIC or ACC_STRICT_INIT flags set.
if (classData.isValue()) {
if (!EModifier.anyOf(mod, ACC_STATIC, ACC_STRICT)) {
environment.warning(pos, "warn.invalid.modifier.for.value",
EModifier.asNames(mod, ClassFileContext.FIELD));
}
}
}
//Fields of classes may set any of the flags in Table 4.5-A.
// However, each field of a class may have at most one of its ACC_PUBLIC, ACC_PRIVATE, and ACC_PROTECTED flags set (JLS §8.3.1),
// and must not have both its ACC_FINAL and ACC_VOLATILE flags set (JLS §8.3.1.4).
int invalidFlags = notValidField(mod);
if (invalidFlags != 0) {
environment.warning(pos, "warn.invalid.modifier.field",
EModifier.asNames(invalidFlags, ClassFileContext.FIELD));
}
if (!validAccess(mod)) {
environment.warning(pos, "warn.invalid.modifier.acc",
EModifier.asNames(mod, ClassFileContext.FIELD));
}
if (both(mod, ACC_FINAL, ACC_VOLATILE)) {
environment.warning(pos, "warn.invalid.modifier.fiva",
EModifier.asNames(mod, ClassFileContext.FIELD));
}
}
}
/**
* Check the modifier flags for the method
*
* @param classData The ClassData for the current class
* @param mod The modifier flags being checked
* @param pos the position of the parser in the file
* @param isInit is the method constructor
* @param isClinit is the method static initializer
*/
public static void checkMethodModifiers(ClassData classData, int mod, long pos, boolean isInit, boolean isClinit) {
final JasmEnvironment environment = classData.getEnvironment();
final int cfvMajorVersion = classData.cfv.major_version();
mod = EModifier.cleanFlags(mod, DEPRECATED_ATTRIBUTE, SYNTHETIC_ATTRIBUTE);
int wrongFlags;
if (!validMethod(mod)) {
wrongFlags = mod & ~EModifier.getFlags(MM_METHOD);
environment.warning(pos, "warn.invalid.modifier.mth",
EModifier.asNames(wrongFlags, ClassFileContext.METHOD));
}
if (!validAccess(mod)) {
environment.warning(pos, "warn.invalid.modifier.mth.acc",
EModifier.asNames(mod, ClassFileContext.METHOD));
}
if (isClinit) { //
// In a class file whose version number is 51.0 or above, a method whose name is must have its ACC_STATIC flag set.
if (classData.cfv.major_version() > 51 && !isStatic(mod)) {
environment.warning(pos, "warn.clinit.static",
EModifier.asNames(mod, ClassFileContext.METHOD));
}
} else { // any method
// interface methods.
if (classData.isInterface()) {
if (isInit) {
environment.warning(pos, "warn.init.in_int");
} else {
validateInterfaceMethod(mod, classData, pos);
}
// class methods
} else {
if (isInit && !validInitMethod(mod)) {
wrongFlags = mod & ~EModifier.getFlags(MM_INIT_METHOD);
environment.warning(pos, "warn.invalid.modifier.init",
EModifier.asNames(wrongFlags, ClassFileContext.METHOD));
} else if (isAbstract(mod)) {
if (!validAbstractMethod(mod)) {
wrongFlags = mod & ~EModifier.getFlags(MM_ABSTRACT_METHOD);
environment.warning(pos, "warn.invalid.modifier.abst",
EModifier.asNames(wrongFlags, ClassFileContext.METHOD));
} else if (isStrict(mod) && (cfvMajorVersion >= 46 && cfvMajorVersion <= 60)) {
environment.warning(pos, "warn.invalid.modifier.strict");
}
}
}
}
}
/**
* Check the modifier flags for the inner-class
*
* @param classData The ClassData for the current class
* @param mod The modifier flags being checked
* @param pos the position of the parser in the file
*/
public static void checkInnerClassModifiers(ClassData classData, int mod, long pos) {
JasmEnvironment environment = classData.getEnvironment();
mod = EModifier.cleanFlags(mod, DEPRECATED_ATTRIBUTE, SYNTHETIC_ATTRIBUTE);
if (!validNestedClass(mod)) {
int wrongFlags = mod & ~EModifier.getFlags(MM_NESTED_CLASS);
environment.warning(pos, "warn.invalid.modifier.innerclass",
EModifier.asNames(wrongFlags, ClassFileContext.INNER_CLASS));
}
}
// Methods of interfaces may have any of the flags in Table 4.6-A set except ACC_PROTECTED, ACC_FINAL, ACC_SYNCHRONIZED,
// and ACC_NATIVE (JLS §9.4). In a class file whose version number is less than 52.0, each method of an interface
// must have its ACC_PUBLIC and ACC_ABSTRACT flags set; in a class file whose version number is 52.0 or above,
// each method of an interface must have exactly one of its ACC_PUBLIC and ACC_PRIVATE flags set.
public static void validateInterfaceMethod(int mod, ClassData cd, long pos) {
final int cfvMajorVersion = cd.cfv.major_version();
final JasmEnvironment environment = cd.getEnvironment();
if (EModifier.anyOf(mod, ACC_PROTECTED, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE)) {
environment.warning(pos, "warn.invalid.modifier.method",
EModifier.asNames(mod, ClassFileContext.METHOD));
}
if (cfvMajorVersion < 52) {
if (!both(mod, ACC_PUBLIC, ACC_ABSTRACT)) {
environment.warning(pos, "warn.invalid.modifier.intmth.less.52",
EModifier.asNames(mod, ClassFileContext.METHOD));
} else { // cfvMajorVersion >= 52
if (!EModifier.onlyOneOfFlags(mod, EModifier.ACC_PUBLIC, ACC_PRIVATE)) {
environment.warning(pos, "warn.invalid.modifier.intmth.is.52",
EModifier.asNames(mod, ClassFileContext.METHOD));
}
}
}
}
}
jtreg8-8.2.1+1+ds1/asmtools/src/org/openjdk/asmtools/jasm/ClassData.java 0000664 0000000 0000000 00000100012 15143236361 0025710 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.asmtools.jasm;
import org.openjdk.asmtools.asmutils.Pair;
import org.openjdk.asmtools.common.outputs.NamedToolOutput;
import org.openjdk.asmtools.common.outputs.ToolOutput;
import org.openjdk.asmtools.common.structure.CFVersion;
import org.openjdk.asmtools.common.structure.EAttribute;
import org.openjdk.asmtools.common.structure.ELocation;
import org.openjdk.asmtools.common.structure.EModifier;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static org.openjdk.asmtools.common.structure.ClassFileContext.INNER_CLASS;
import static org.openjdk.asmtools.common.structure.EAttribute.ATT_Record;
import static org.openjdk.asmtools.jasm.ClassData.CoreClasses.PLACE.HEADER;
import static org.openjdk.asmtools.jasm.ClassFileConst.ConstType;
import static org.openjdk.asmtools.jasm.ClassFileConst.ConstType.CONSTANT_DYNAMIC;
import static org.openjdk.asmtools.jasm.ClassFileConst.ConstType.CONSTANT_INVOKEDYNAMIC;
import static org.openjdk.asmtools.jasm.ClassFileConst.JAVA_MAGIC;
import static org.openjdk.asmtools.jasm.Indexer.NotSet;
/**
* ClassData
*