├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── include ├── classfile_constants.h ├── gen.sh ├── jawt.h ├── jawt_md.h ├── jdwpTransport.h ├── jmm.h ├── jni.h ├── jni_md.h ├── jvm.h ├── jvm_md.h ├── jvmti.h └── jvmticmlr.h └── src ├── bitfield.rs ├── classfile_constants.rs ├── jawt.rs ├── jdwpTransport.rs ├── jmm.rs ├── jni.rs ├── jvm.rs ├── jvmti.rs ├── jvmticmlr.rs ├── lib.rs ├── varargs.rs └── weak.rs /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | /target 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "jvm-rs" 3 | description = "Bindings for the JVM and its interfaces" 4 | homepage = "https://github.com/x4e/rs-jvm-bindings" 5 | repository = "https://github.com/x4e/rs-jvm-bindings" 6 | version = "1.0.1" 7 | authors = ["x4e "] 8 | edition = "2018" 9 | license-file = "LICENSE" 10 | readme = "README.md" 11 | keywords = ["jvm", "java", "jmm", "jni", "jvmti"] 12 | categories = ["external-ffi-bindings"] 13 | 14 | [dependencies] 15 | 16 | [target.'cfg(windows)'.dependencies] 17 | winapi = { version = "0.3.9", features = ["libloaderapi"] } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jvm-rs 2 | 3 | JVM bindings for rust. 4 | 5 | Currently bound to JVM 15. 6 | 7 | Generated with `bindgen --no-layout-tests` 8 | 9 | ## Usage 10 | 11 | Add to Cargo.toml 12 | ```toml 13 | jvm-rs = "0.1.0" 14 | ``` 15 | 16 | Follow documentation: https://docs.rs/jvm-rs/0.1.0/jvm_rs/ 17 | 18 | ## Interfaces this supports 19 | * [classfile_constants](https://github.com/openjdk/jdk/blob/jdk-16+24/src/java.base/share/native/include/classfile_constants.h.template) 20 | * [jawt](https://github.com/openjdk/jdk/blob/jdk-16+24/src/java.desktop/share/native/include/jawt.h) 21 | * [jdwp](https://github.com/openjdk/jdk/blob/jdk-16+24/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h) 22 | * [jmm](https://github.com/openjdk/jdk/blob/jdk-16+24/src/hotspot/share/include/jmm.h) 23 | * [jni](https://github.com/openjdk/jdk/blob/jdk-16+24/src/java.base/share/native/include/jni.h) 24 | * [jvm](https://github.com/openjdk/jdk/blob/jdk-16+24/src/hotspot/share/include/jvm.h) 25 | * [jvmti](https://github.com/openjdk/jdk/blob/jdk-16+24/src/hotspot/share/prims/jvmtiH.xsl) 26 | * [jvmticmlr](https://github.com/openjdk/jdk/blob/jdk-16+24/src/java.base/share/native/include/jvmticmlr.h) 27 | -------------------------------------------------------------------------------- /include/classfile_constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef CLASSFILE_CONSTANTS_H 27 | #define CLASSFILE_CONSTANTS_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* Classfile version number for this information */ 34 | #define JVM_CLASSFILE_MAJOR_VERSION 59 35 | #define JVM_CLASSFILE_MINOR_VERSION 0 36 | 37 | /* Flags */ 38 | 39 | enum { 40 | JVM_ACC_PUBLIC = 0x0001, 41 | JVM_ACC_PRIVATE = 0x0002, 42 | JVM_ACC_PROTECTED = 0x0004, 43 | JVM_ACC_STATIC = 0x0008, 44 | JVM_ACC_FINAL = 0x0010, 45 | JVM_ACC_SYNCHRONIZED = 0x0020, 46 | JVM_ACC_SUPER = 0x0020, 47 | JVM_ACC_VOLATILE = 0x0040, 48 | JVM_ACC_BRIDGE = 0x0040, 49 | JVM_ACC_TRANSIENT = 0x0080, 50 | JVM_ACC_VARARGS = 0x0080, 51 | JVM_ACC_NATIVE = 0x0100, 52 | JVM_ACC_INTERFACE = 0x0200, 53 | JVM_ACC_ABSTRACT = 0x0400, 54 | JVM_ACC_STRICT = 0x0800, 55 | JVM_ACC_SYNTHETIC = 0x1000, 56 | JVM_ACC_ANNOTATION = 0x2000, 57 | JVM_ACC_ENUM = 0x4000, 58 | JVM_ACC_MODULE = 0x8000 59 | }; 60 | 61 | #define JVM_ACC_PUBLIC_BIT 0 62 | #define JVM_ACC_PRIVATE_BIT 1 63 | #define JVM_ACC_PROTECTED_BIT 2 64 | #define JVM_ACC_STATIC_BIT 3 65 | #define JVM_ACC_FINAL_BIT 4 66 | #define JVM_ACC_SYNCHRONIZED_BIT 5 67 | #define JVM_ACC_SUPER_BIT 5 68 | #define JVM_ACC_VOLATILE_BIT 6 69 | #define JVM_ACC_BRIDGE_BIT 6 70 | #define JVM_ACC_TRANSIENT_BIT 7 71 | #define JVM_ACC_VARARGS_BIT 7 72 | #define JVM_ACC_NATIVE_BIT 8 73 | #define JVM_ACC_INTERFACE_BIT 9 74 | #define JVM_ACC_ABSTRACT_BIT 10 75 | #define JVM_ACC_STRICT_BIT 11 76 | #define JVM_ACC_SYNTHETIC_BIT 12 77 | #define JVM_ACC_ANNOTATION_BIT 13 78 | #define JVM_ACC_ENUM_BIT 14 79 | 80 | /* Used in newarray instruction. */ 81 | 82 | enum { 83 | JVM_T_BOOLEAN = 4, 84 | JVM_T_CHAR = 5, 85 | JVM_T_FLOAT = 6, 86 | JVM_T_DOUBLE = 7, 87 | JVM_T_BYTE = 8, 88 | JVM_T_SHORT = 9, 89 | JVM_T_INT = 10, 90 | JVM_T_LONG = 11 91 | }; 92 | 93 | /* Constant Pool Entries */ 94 | 95 | enum { 96 | JVM_CONSTANT_Utf8 = 1, 97 | JVM_CONSTANT_Unicode = 2, /* unused */ 98 | JVM_CONSTANT_Integer = 3, 99 | JVM_CONSTANT_Float = 4, 100 | JVM_CONSTANT_Long = 5, 101 | JVM_CONSTANT_Double = 6, 102 | JVM_CONSTANT_Class = 7, 103 | JVM_CONSTANT_String = 8, 104 | JVM_CONSTANT_Fieldref = 9, 105 | JVM_CONSTANT_Methodref = 10, 106 | JVM_CONSTANT_InterfaceMethodref = 11, 107 | JVM_CONSTANT_NameAndType = 12, 108 | JVM_CONSTANT_MethodHandle = 15, // JSR 292 109 | JVM_CONSTANT_MethodType = 16, // JSR 292 110 | JVM_CONSTANT_Dynamic = 17, 111 | JVM_CONSTANT_InvokeDynamic = 18, 112 | JVM_CONSTANT_Module = 19, 113 | JVM_CONSTANT_Package = 20, 114 | JVM_CONSTANT_ExternalMax = 20 115 | }; 116 | 117 | /* JVM_CONSTANT_MethodHandle subtypes */ 118 | enum { 119 | JVM_REF_getField = 1, 120 | JVM_REF_getStatic = 2, 121 | JVM_REF_putField = 3, 122 | JVM_REF_putStatic = 4, 123 | JVM_REF_invokeVirtual = 5, 124 | JVM_REF_invokeStatic = 6, 125 | JVM_REF_invokeSpecial = 7, 126 | JVM_REF_newInvokeSpecial = 8, 127 | JVM_REF_invokeInterface = 9 128 | }; 129 | 130 | /* StackMapTable type item numbers */ 131 | 132 | enum { 133 | JVM_ITEM_Top = 0, 134 | JVM_ITEM_Integer = 1, 135 | JVM_ITEM_Float = 2, 136 | JVM_ITEM_Double = 3, 137 | JVM_ITEM_Long = 4, 138 | JVM_ITEM_Null = 5, 139 | JVM_ITEM_UninitializedThis = 6, 140 | JVM_ITEM_Object = 7, 141 | JVM_ITEM_Uninitialized = 8 142 | }; 143 | 144 | /* Type signatures */ 145 | 146 | enum { 147 | JVM_SIGNATURE_SLASH = '/', 148 | JVM_SIGNATURE_DOT = '.', 149 | JVM_SIGNATURE_SPECIAL = '<', 150 | JVM_SIGNATURE_ENDSPECIAL = '>', 151 | JVM_SIGNATURE_ARRAY = '[', 152 | JVM_SIGNATURE_BYTE = 'B', 153 | JVM_SIGNATURE_CHAR = 'C', 154 | JVM_SIGNATURE_CLASS = 'L', 155 | JVM_SIGNATURE_ENDCLASS = ';', 156 | JVM_SIGNATURE_ENUM = 'E', 157 | JVM_SIGNATURE_FLOAT = 'F', 158 | JVM_SIGNATURE_DOUBLE = 'D', 159 | JVM_SIGNATURE_FUNC = '(', 160 | JVM_SIGNATURE_ENDFUNC = ')', 161 | JVM_SIGNATURE_INT = 'I', 162 | JVM_SIGNATURE_LONG = 'J', 163 | JVM_SIGNATURE_SHORT = 'S', 164 | JVM_SIGNATURE_VOID = 'V', 165 | JVM_SIGNATURE_BOOLEAN = 'Z' 166 | }; 167 | 168 | /* Opcodes */ 169 | 170 | enum { 171 | JVM_OPC_nop = 0, 172 | JVM_OPC_aconst_null = 1, 173 | JVM_OPC_iconst_m1 = 2, 174 | JVM_OPC_iconst_0 = 3, 175 | JVM_OPC_iconst_1 = 4, 176 | JVM_OPC_iconst_2 = 5, 177 | JVM_OPC_iconst_3 = 6, 178 | JVM_OPC_iconst_4 = 7, 179 | JVM_OPC_iconst_5 = 8, 180 | JVM_OPC_lconst_0 = 9, 181 | JVM_OPC_lconst_1 = 10, 182 | JVM_OPC_fconst_0 = 11, 183 | JVM_OPC_fconst_1 = 12, 184 | JVM_OPC_fconst_2 = 13, 185 | JVM_OPC_dconst_0 = 14, 186 | JVM_OPC_dconst_1 = 15, 187 | JVM_OPC_bipush = 16, 188 | JVM_OPC_sipush = 17, 189 | JVM_OPC_ldc = 18, 190 | JVM_OPC_ldc_w = 19, 191 | JVM_OPC_ldc2_w = 20, 192 | JVM_OPC_iload = 21, 193 | JVM_OPC_lload = 22, 194 | JVM_OPC_fload = 23, 195 | JVM_OPC_dload = 24, 196 | JVM_OPC_aload = 25, 197 | JVM_OPC_iload_0 = 26, 198 | JVM_OPC_iload_1 = 27, 199 | JVM_OPC_iload_2 = 28, 200 | JVM_OPC_iload_3 = 29, 201 | JVM_OPC_lload_0 = 30, 202 | JVM_OPC_lload_1 = 31, 203 | JVM_OPC_lload_2 = 32, 204 | JVM_OPC_lload_3 = 33, 205 | JVM_OPC_fload_0 = 34, 206 | JVM_OPC_fload_1 = 35, 207 | JVM_OPC_fload_2 = 36, 208 | JVM_OPC_fload_3 = 37, 209 | JVM_OPC_dload_0 = 38, 210 | JVM_OPC_dload_1 = 39, 211 | JVM_OPC_dload_2 = 40, 212 | JVM_OPC_dload_3 = 41, 213 | JVM_OPC_aload_0 = 42, 214 | JVM_OPC_aload_1 = 43, 215 | JVM_OPC_aload_2 = 44, 216 | JVM_OPC_aload_3 = 45, 217 | JVM_OPC_iaload = 46, 218 | JVM_OPC_laload = 47, 219 | JVM_OPC_faload = 48, 220 | JVM_OPC_daload = 49, 221 | JVM_OPC_aaload = 50, 222 | JVM_OPC_baload = 51, 223 | JVM_OPC_caload = 52, 224 | JVM_OPC_saload = 53, 225 | JVM_OPC_istore = 54, 226 | JVM_OPC_lstore = 55, 227 | JVM_OPC_fstore = 56, 228 | JVM_OPC_dstore = 57, 229 | JVM_OPC_astore = 58, 230 | JVM_OPC_istore_0 = 59, 231 | JVM_OPC_istore_1 = 60, 232 | JVM_OPC_istore_2 = 61, 233 | JVM_OPC_istore_3 = 62, 234 | JVM_OPC_lstore_0 = 63, 235 | JVM_OPC_lstore_1 = 64, 236 | JVM_OPC_lstore_2 = 65, 237 | JVM_OPC_lstore_3 = 66, 238 | JVM_OPC_fstore_0 = 67, 239 | JVM_OPC_fstore_1 = 68, 240 | JVM_OPC_fstore_2 = 69, 241 | JVM_OPC_fstore_3 = 70, 242 | JVM_OPC_dstore_0 = 71, 243 | JVM_OPC_dstore_1 = 72, 244 | JVM_OPC_dstore_2 = 73, 245 | JVM_OPC_dstore_3 = 74, 246 | JVM_OPC_astore_0 = 75, 247 | JVM_OPC_astore_1 = 76, 248 | JVM_OPC_astore_2 = 77, 249 | JVM_OPC_astore_3 = 78, 250 | JVM_OPC_iastore = 79, 251 | JVM_OPC_lastore = 80, 252 | JVM_OPC_fastore = 81, 253 | JVM_OPC_dastore = 82, 254 | JVM_OPC_aastore = 83, 255 | JVM_OPC_bastore = 84, 256 | JVM_OPC_castore = 85, 257 | JVM_OPC_sastore = 86, 258 | JVM_OPC_pop = 87, 259 | JVM_OPC_pop2 = 88, 260 | JVM_OPC_dup = 89, 261 | JVM_OPC_dup_x1 = 90, 262 | JVM_OPC_dup_x2 = 91, 263 | JVM_OPC_dup2 = 92, 264 | JVM_OPC_dup2_x1 = 93, 265 | JVM_OPC_dup2_x2 = 94, 266 | JVM_OPC_swap = 95, 267 | JVM_OPC_iadd = 96, 268 | JVM_OPC_ladd = 97, 269 | JVM_OPC_fadd = 98, 270 | JVM_OPC_dadd = 99, 271 | JVM_OPC_isub = 100, 272 | JVM_OPC_lsub = 101, 273 | JVM_OPC_fsub = 102, 274 | JVM_OPC_dsub = 103, 275 | JVM_OPC_imul = 104, 276 | JVM_OPC_lmul = 105, 277 | JVM_OPC_fmul = 106, 278 | JVM_OPC_dmul = 107, 279 | JVM_OPC_idiv = 108, 280 | JVM_OPC_ldiv = 109, 281 | JVM_OPC_fdiv = 110, 282 | JVM_OPC_ddiv = 111, 283 | JVM_OPC_irem = 112, 284 | JVM_OPC_lrem = 113, 285 | JVM_OPC_frem = 114, 286 | JVM_OPC_drem = 115, 287 | JVM_OPC_ineg = 116, 288 | JVM_OPC_lneg = 117, 289 | JVM_OPC_fneg = 118, 290 | JVM_OPC_dneg = 119, 291 | JVM_OPC_ishl = 120, 292 | JVM_OPC_lshl = 121, 293 | JVM_OPC_ishr = 122, 294 | JVM_OPC_lshr = 123, 295 | JVM_OPC_iushr = 124, 296 | JVM_OPC_lushr = 125, 297 | JVM_OPC_iand = 126, 298 | JVM_OPC_land = 127, 299 | JVM_OPC_ior = 128, 300 | JVM_OPC_lor = 129, 301 | JVM_OPC_ixor = 130, 302 | JVM_OPC_lxor = 131, 303 | JVM_OPC_iinc = 132, 304 | JVM_OPC_i2l = 133, 305 | JVM_OPC_i2f = 134, 306 | JVM_OPC_i2d = 135, 307 | JVM_OPC_l2i = 136, 308 | JVM_OPC_l2f = 137, 309 | JVM_OPC_l2d = 138, 310 | JVM_OPC_f2i = 139, 311 | JVM_OPC_f2l = 140, 312 | JVM_OPC_f2d = 141, 313 | JVM_OPC_d2i = 142, 314 | JVM_OPC_d2l = 143, 315 | JVM_OPC_d2f = 144, 316 | JVM_OPC_i2b = 145, 317 | JVM_OPC_i2c = 146, 318 | JVM_OPC_i2s = 147, 319 | JVM_OPC_lcmp = 148, 320 | JVM_OPC_fcmpl = 149, 321 | JVM_OPC_fcmpg = 150, 322 | JVM_OPC_dcmpl = 151, 323 | JVM_OPC_dcmpg = 152, 324 | JVM_OPC_ifeq = 153, 325 | JVM_OPC_ifne = 154, 326 | JVM_OPC_iflt = 155, 327 | JVM_OPC_ifge = 156, 328 | JVM_OPC_ifgt = 157, 329 | JVM_OPC_ifle = 158, 330 | JVM_OPC_if_icmpeq = 159, 331 | JVM_OPC_if_icmpne = 160, 332 | JVM_OPC_if_icmplt = 161, 333 | JVM_OPC_if_icmpge = 162, 334 | JVM_OPC_if_icmpgt = 163, 335 | JVM_OPC_if_icmple = 164, 336 | JVM_OPC_if_acmpeq = 165, 337 | JVM_OPC_if_acmpne = 166, 338 | JVM_OPC_goto = 167, 339 | JVM_OPC_jsr = 168, 340 | JVM_OPC_ret = 169, 341 | JVM_OPC_tableswitch = 170, 342 | JVM_OPC_lookupswitch = 171, 343 | JVM_OPC_ireturn = 172, 344 | JVM_OPC_lreturn = 173, 345 | JVM_OPC_freturn = 174, 346 | JVM_OPC_dreturn = 175, 347 | JVM_OPC_areturn = 176, 348 | JVM_OPC_return = 177, 349 | JVM_OPC_getstatic = 178, 350 | JVM_OPC_putstatic = 179, 351 | JVM_OPC_getfield = 180, 352 | JVM_OPC_putfield = 181, 353 | JVM_OPC_invokevirtual = 182, 354 | JVM_OPC_invokespecial = 183, 355 | JVM_OPC_invokestatic = 184, 356 | JVM_OPC_invokeinterface = 185, 357 | JVM_OPC_invokedynamic = 186, 358 | JVM_OPC_new = 187, 359 | JVM_OPC_newarray = 188, 360 | JVM_OPC_anewarray = 189, 361 | JVM_OPC_arraylength = 190, 362 | JVM_OPC_athrow = 191, 363 | JVM_OPC_checkcast = 192, 364 | JVM_OPC_instanceof = 193, 365 | JVM_OPC_monitorenter = 194, 366 | JVM_OPC_monitorexit = 195, 367 | JVM_OPC_wide = 196, 368 | JVM_OPC_multianewarray = 197, 369 | JVM_OPC_ifnull = 198, 370 | JVM_OPC_ifnonnull = 199, 371 | JVM_OPC_goto_w = 200, 372 | JVM_OPC_jsr_w = 201, 373 | JVM_OPC_MAX = 201 374 | }; 375 | 376 | /* Opcode length initializer, use with something like: 377 | * unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER; 378 | */ 379 | #define JVM_OPCODE_LENGTH_INITIALIZER { \ 380 | 1, /* nop */ \ 381 | 1, /* aconst_null */ \ 382 | 1, /* iconst_m1 */ \ 383 | 1, /* iconst_0 */ \ 384 | 1, /* iconst_1 */ \ 385 | 1, /* iconst_2 */ \ 386 | 1, /* iconst_3 */ \ 387 | 1, /* iconst_4 */ \ 388 | 1, /* iconst_5 */ \ 389 | 1, /* lconst_0 */ \ 390 | 1, /* lconst_1 */ \ 391 | 1, /* fconst_0 */ \ 392 | 1, /* fconst_1 */ \ 393 | 1, /* fconst_2 */ \ 394 | 1, /* dconst_0 */ \ 395 | 1, /* dconst_1 */ \ 396 | 2, /* bipush */ \ 397 | 3, /* sipush */ \ 398 | 2, /* ldc */ \ 399 | 3, /* ldc_w */ \ 400 | 3, /* ldc2_w */ \ 401 | 2, /* iload */ \ 402 | 2, /* lload */ \ 403 | 2, /* fload */ \ 404 | 2, /* dload */ \ 405 | 2, /* aload */ \ 406 | 1, /* iload_0 */ \ 407 | 1, /* iload_1 */ \ 408 | 1, /* iload_2 */ \ 409 | 1, /* iload_3 */ \ 410 | 1, /* lload_0 */ \ 411 | 1, /* lload_1 */ \ 412 | 1, /* lload_2 */ \ 413 | 1, /* lload_3 */ \ 414 | 1, /* fload_0 */ \ 415 | 1, /* fload_1 */ \ 416 | 1, /* fload_2 */ \ 417 | 1, /* fload_3 */ \ 418 | 1, /* dload_0 */ \ 419 | 1, /* dload_1 */ \ 420 | 1, /* dload_2 */ \ 421 | 1, /* dload_3 */ \ 422 | 1, /* aload_0 */ \ 423 | 1, /* aload_1 */ \ 424 | 1, /* aload_2 */ \ 425 | 1, /* aload_3 */ \ 426 | 1, /* iaload */ \ 427 | 1, /* laload */ \ 428 | 1, /* faload */ \ 429 | 1, /* daload */ \ 430 | 1, /* aaload */ \ 431 | 1, /* baload */ \ 432 | 1, /* caload */ \ 433 | 1, /* saload */ \ 434 | 2, /* istore */ \ 435 | 2, /* lstore */ \ 436 | 2, /* fstore */ \ 437 | 2, /* dstore */ \ 438 | 2, /* astore */ \ 439 | 1, /* istore_0 */ \ 440 | 1, /* istore_1 */ \ 441 | 1, /* istore_2 */ \ 442 | 1, /* istore_3 */ \ 443 | 1, /* lstore_0 */ \ 444 | 1, /* lstore_1 */ \ 445 | 1, /* lstore_2 */ \ 446 | 1, /* lstore_3 */ \ 447 | 1, /* fstore_0 */ \ 448 | 1, /* fstore_1 */ \ 449 | 1, /* fstore_2 */ \ 450 | 1, /* fstore_3 */ \ 451 | 1, /* dstore_0 */ \ 452 | 1, /* dstore_1 */ \ 453 | 1, /* dstore_2 */ \ 454 | 1, /* dstore_3 */ \ 455 | 1, /* astore_0 */ \ 456 | 1, /* astore_1 */ \ 457 | 1, /* astore_2 */ \ 458 | 1, /* astore_3 */ \ 459 | 1, /* iastore */ \ 460 | 1, /* lastore */ \ 461 | 1, /* fastore */ \ 462 | 1, /* dastore */ \ 463 | 1, /* aastore */ \ 464 | 1, /* bastore */ \ 465 | 1, /* castore */ \ 466 | 1, /* sastore */ \ 467 | 1, /* pop */ \ 468 | 1, /* pop2 */ \ 469 | 1, /* dup */ \ 470 | 1, /* dup_x1 */ \ 471 | 1, /* dup_x2 */ \ 472 | 1, /* dup2 */ \ 473 | 1, /* dup2_x1 */ \ 474 | 1, /* dup2_x2 */ \ 475 | 1, /* swap */ \ 476 | 1, /* iadd */ \ 477 | 1, /* ladd */ \ 478 | 1, /* fadd */ \ 479 | 1, /* dadd */ \ 480 | 1, /* isub */ \ 481 | 1, /* lsub */ \ 482 | 1, /* fsub */ \ 483 | 1, /* dsub */ \ 484 | 1, /* imul */ \ 485 | 1, /* lmul */ \ 486 | 1, /* fmul */ \ 487 | 1, /* dmul */ \ 488 | 1, /* idiv */ \ 489 | 1, /* ldiv */ \ 490 | 1, /* fdiv */ \ 491 | 1, /* ddiv */ \ 492 | 1, /* irem */ \ 493 | 1, /* lrem */ \ 494 | 1, /* frem */ \ 495 | 1, /* drem */ \ 496 | 1, /* ineg */ \ 497 | 1, /* lneg */ \ 498 | 1, /* fneg */ \ 499 | 1, /* dneg */ \ 500 | 1, /* ishl */ \ 501 | 1, /* lshl */ \ 502 | 1, /* ishr */ \ 503 | 1, /* lshr */ \ 504 | 1, /* iushr */ \ 505 | 1, /* lushr */ \ 506 | 1, /* iand */ \ 507 | 1, /* land */ \ 508 | 1, /* ior */ \ 509 | 1, /* lor */ \ 510 | 1, /* ixor */ \ 511 | 1, /* lxor */ \ 512 | 3, /* iinc */ \ 513 | 1, /* i2l */ \ 514 | 1, /* i2f */ \ 515 | 1, /* i2d */ \ 516 | 1, /* l2i */ \ 517 | 1, /* l2f */ \ 518 | 1, /* l2d */ \ 519 | 1, /* f2i */ \ 520 | 1, /* f2l */ \ 521 | 1, /* f2d */ \ 522 | 1, /* d2i */ \ 523 | 1, /* d2l */ \ 524 | 1, /* d2f */ \ 525 | 1, /* i2b */ \ 526 | 1, /* i2c */ \ 527 | 1, /* i2s */ \ 528 | 1, /* lcmp */ \ 529 | 1, /* fcmpl */ \ 530 | 1, /* fcmpg */ \ 531 | 1, /* dcmpl */ \ 532 | 1, /* dcmpg */ \ 533 | 3, /* ifeq */ \ 534 | 3, /* ifne */ \ 535 | 3, /* iflt */ \ 536 | 3, /* ifge */ \ 537 | 3, /* ifgt */ \ 538 | 3, /* ifle */ \ 539 | 3, /* if_icmpeq */ \ 540 | 3, /* if_icmpne */ \ 541 | 3, /* if_icmplt */ \ 542 | 3, /* if_icmpge */ \ 543 | 3, /* if_icmpgt */ \ 544 | 3, /* if_icmple */ \ 545 | 3, /* if_acmpeq */ \ 546 | 3, /* if_acmpne */ \ 547 | 3, /* goto */ \ 548 | 3, /* jsr */ \ 549 | 2, /* ret */ \ 550 | 99, /* tableswitch */ \ 551 | 99, /* lookupswitch */ \ 552 | 1, /* ireturn */ \ 553 | 1, /* lreturn */ \ 554 | 1, /* freturn */ \ 555 | 1, /* dreturn */ \ 556 | 1, /* areturn */ \ 557 | 1, /* return */ \ 558 | 3, /* getstatic */ \ 559 | 3, /* putstatic */ \ 560 | 3, /* getfield */ \ 561 | 3, /* putfield */ \ 562 | 3, /* invokevirtual */ \ 563 | 3, /* invokespecial */ \ 564 | 3, /* invokestatic */ \ 565 | 5, /* invokeinterface */ \ 566 | 5, /* invokedynamic */ \ 567 | 3, /* new */ \ 568 | 2, /* newarray */ \ 569 | 3, /* anewarray */ \ 570 | 1, /* arraylength */ \ 571 | 1, /* athrow */ \ 572 | 3, /* checkcast */ \ 573 | 3, /* instanceof */ \ 574 | 1, /* monitorenter */ \ 575 | 1, /* monitorexit */ \ 576 | 0, /* wide */ \ 577 | 4, /* multianewarray */ \ 578 | 3, /* ifnull */ \ 579 | 3, /* ifnonnull */ \ 580 | 5, /* goto_w */ \ 581 | 5 /* jsr_w */ \ 582 | } 583 | 584 | #ifdef __cplusplus 585 | } /* extern "C" */ 586 | #endif /* __cplusplus */ 587 | 588 | #endif /* CLASSFILE_CONSTANTS */ 589 | -------------------------------------------------------------------------------- /include/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bindgen $1.h --no-layout-tests -o $1.rs 4 | -------------------------------------------------------------------------------- /include/jawt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVASOFT_JAWT_H_ 27 | #define _JAVASOFT_JAWT_H_ 28 | 29 | #include "jni.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* 36 | * AWT native interface. 37 | * 38 | * The AWT native interface allows a native C or C++ application a means 39 | * by which to access native structures in AWT. This is to facilitate moving 40 | * legacy C and C++ applications to Java and to target the needs of the 41 | * developers who need to do their own native rendering to canvases 42 | * for performance or other reasons. 43 | * 44 | * Conversely it also provides mechanisms for an application which already 45 | * has a native window to provide that to AWT for AWT rendering. 46 | * 47 | * Since every platform may be different in its native data structures 48 | * and APIs for windowing systems the application must necessarily 49 | * provided per-platform source and compile and deliver per-platform 50 | * native code to use this API. 51 | * 52 | * These interfaces are not part of the Java SE specification and 53 | * a VM is not required to implement this API. However it is strongly 54 | * recommended that all implementations which support headful AWT 55 | * also support these interfaces. 56 | * 57 | */ 58 | 59 | /* 60 | * AWT Native Drawing Surface (JAWT_DrawingSurface). 61 | * 62 | * For each platform, there is a native drawing surface structure. This 63 | * platform-specific structure can be found in jawt_md.h. It is recommended 64 | * that additional platforms follow the same model. It is also recommended 65 | * that VMs on all platforms support the existing structures in jawt_md.h. 66 | * 67 | ******************* 68 | * EXAMPLE OF USAGE: 69 | ******************* 70 | * 71 | * In Win32, a programmer wishes to access the HWND of a canvas to perform 72 | * native rendering into it. The programmer has declared the paint() method 73 | * for their canvas subclass to be native: 74 | * 75 | * 76 | * MyCanvas.java: 77 | * 78 | * import java.awt.*; 79 | * 80 | * public class MyCanvas extends Canvas { 81 | * 82 | * static { 83 | * System.loadLibrary("mylib"); 84 | * } 85 | * 86 | * public native void paint(Graphics g); 87 | * } 88 | * 89 | * 90 | * myfile.c: 91 | * 92 | * #include "jawt_md.h" 93 | * #include 94 | * 95 | * JNIEXPORT void JNICALL 96 | * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) 97 | * { 98 | * JAWT awt; 99 | * JAWT_DrawingSurface* ds; 100 | * JAWT_DrawingSurfaceInfo* dsi; 101 | * JAWT_Win32DrawingSurfaceInfo* dsi_win; 102 | * jboolean result; 103 | * jint lock; 104 | * 105 | * // Get the AWT. Request version 9 to access features in that release. 106 | * awt.version = JAWT_VERSION_9; 107 | * result = JAWT_GetAWT(env, &awt); 108 | * assert(result != JNI_FALSE); 109 | * 110 | * // Get the drawing surface 111 | * ds = awt.GetDrawingSurface(env, canvas); 112 | * assert(ds != NULL); 113 | * 114 | * // Lock the drawing surface 115 | * lock = ds->Lock(ds); 116 | * assert((lock & JAWT_LOCK_ERROR) == 0); 117 | * 118 | * // Get the drawing surface info 119 | * dsi = ds->GetDrawingSurfaceInfo(ds); 120 | * 121 | * // Get the platform-specific drawing info 122 | * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; 123 | * 124 | * ////////////////////////////// 125 | * // !!! DO PAINTING HERE !!! // 126 | * ////////////////////////////// 127 | * 128 | * // Free the drawing surface info 129 | * ds->FreeDrawingSurfaceInfo(dsi); 130 | * 131 | * // Unlock the drawing surface 132 | * ds->Unlock(ds); 133 | * 134 | * // Free the drawing surface 135 | * awt.FreeDrawingSurface(ds); 136 | * } 137 | * 138 | */ 139 | 140 | /* 141 | * JAWT_Rectangle 142 | * Structure for a native rectangle. 143 | */ 144 | typedef struct jawt_Rectangle { 145 | jint x; 146 | jint y; 147 | jint width; 148 | jint height; 149 | } JAWT_Rectangle; 150 | 151 | struct jawt_DrawingSurface; 152 | 153 | /* 154 | * JAWT_DrawingSurfaceInfo 155 | * Structure for containing the underlying drawing information of a component. 156 | */ 157 | typedef struct jawt_DrawingSurfaceInfo { 158 | /* 159 | * Pointer to the platform-specific information. This can be safely 160 | * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a 161 | * JAWT_X11DrawingSurfaceInfo on Linux and Solaris. On Mac OS X this is a 162 | * pointer to a NSObject that conforms to the JAWT_SurfaceLayers 163 | * protocol. See jawt_md.h for details. 164 | */ 165 | void* platformInfo; 166 | /* Cached pointer to the underlying drawing surface */ 167 | struct jawt_DrawingSurface* ds; 168 | /* Bounding rectangle of the drawing surface */ 169 | JAWT_Rectangle bounds; 170 | /* Number of rectangles in the clip */ 171 | jint clipSize; 172 | /* Clip rectangle array */ 173 | JAWT_Rectangle* clip; 174 | } JAWT_DrawingSurfaceInfo; 175 | 176 | #define JAWT_LOCK_ERROR 0x00000001 177 | #define JAWT_LOCK_CLIP_CHANGED 0x00000002 178 | #define JAWT_LOCK_BOUNDS_CHANGED 0x00000004 179 | #define JAWT_LOCK_SURFACE_CHANGED 0x00000008 180 | 181 | /* 182 | * JAWT_DrawingSurface 183 | * Structure for containing the underlying drawing information of a component. 184 | * All operations on a JAWT_DrawingSurface MUST be performed from the same 185 | * thread as the call to GetDrawingSurface. 186 | */ 187 | typedef struct jawt_DrawingSurface { 188 | /* 189 | * Cached reference to the Java environment of the calling thread. 190 | * If Lock(), Unlock(), GetDrawingSurfaceInfo() or 191 | * FreeDrawingSurfaceInfo() are called from a different thread, 192 | * this data member should be set before calling those functions. 193 | */ 194 | JNIEnv* env; 195 | /* Cached reference to the target object */ 196 | jobject target; 197 | /* 198 | * Lock the surface of the target component for native rendering. 199 | * When finished drawing, the surface must be unlocked with 200 | * Unlock(). This function returns a bitmask with one or more of the 201 | * following values: 202 | * 203 | * JAWT_LOCK_ERROR - When an error has occurred and the surface could not 204 | * be locked. 205 | * 206 | * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. 207 | * 208 | * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. 209 | * 210 | * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed 211 | */ 212 | jint (JNICALL *Lock) 213 | (struct jawt_DrawingSurface* ds); 214 | /* 215 | * Get the drawing surface info. 216 | * The value returned may be cached, but the values may change if 217 | * additional calls to Lock() or Unlock() are made. 218 | * Lock() must be called before this can return a valid value. 219 | * Returns NULL if an error has occurred. 220 | * When finished with the returned value, FreeDrawingSurfaceInfo must be 221 | * called. 222 | */ 223 | JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo) 224 | (struct jawt_DrawingSurface* ds); 225 | /* 226 | * Free the drawing surface info. 227 | */ 228 | void (JNICALL *FreeDrawingSurfaceInfo) 229 | (JAWT_DrawingSurfaceInfo* dsi); 230 | /* 231 | * Unlock the drawing surface of the target component for native rendering. 232 | */ 233 | void (JNICALL *Unlock) 234 | (struct jawt_DrawingSurface* ds); 235 | } JAWT_DrawingSurface; 236 | 237 | /* 238 | * JAWT 239 | * Structure for containing native AWT functions. 240 | */ 241 | typedef struct jawt { 242 | /* 243 | * Version of this structure. This must always be set before 244 | * calling JAWT_GetAWT(). It affects the functions returned. 245 | * Must be one of the known pre-defined versions. 246 | */ 247 | jint version; 248 | /* 249 | * Return a drawing surface from a target jobject. This value 250 | * may be cached. 251 | * Returns NULL if an error has occurred. 252 | * Target must be a java.awt.Component (should be a Canvas 253 | * or Window for native rendering). 254 | * FreeDrawingSurface() must be called when finished with the 255 | * returned JAWT_DrawingSurface. 256 | */ 257 | JAWT_DrawingSurface* (JNICALL *GetDrawingSurface) 258 | (JNIEnv* env, jobject target); 259 | /* 260 | * Free the drawing surface allocated in GetDrawingSurface. 261 | */ 262 | void (JNICALL *FreeDrawingSurface) 263 | (JAWT_DrawingSurface* ds); 264 | /* 265 | * Since 1.4 266 | * Locks the entire AWT for synchronization purposes 267 | */ 268 | void (JNICALL *Lock)(JNIEnv* env); 269 | /* 270 | * Since 1.4 271 | * Unlocks the entire AWT for synchronization purposes 272 | */ 273 | void (JNICALL *Unlock)(JNIEnv* env); 274 | /* 275 | * Since 1.4 276 | * Returns a reference to a java.awt.Component from a native 277 | * platform handle. On Windows, this corresponds to an HWND; 278 | * on Solaris and Linux, this is a Drawable. For other platforms, 279 | * see the appropriate machine-dependent header file for a description. 280 | * The reference returned by this function is a local 281 | * reference that is only valid in this environment. 282 | * This function returns a NULL reference if no component could be 283 | * found with matching platform information. 284 | */ 285 | jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); 286 | 287 | /** 288 | * Since 9 289 | * Creates a java.awt.Frame placed in a native container. Container is 290 | * referenced by the native platform handle. For example on Windows this 291 | * corresponds to an HWND. For other platforms, see the appropriate 292 | * machine-dependent header file for a description. The reference returned 293 | * by this function is a local reference that is only valid in this 294 | * environment. This function returns a NULL reference if no frame could be 295 | * created with matching platform information. 296 | */ 297 | jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo); 298 | 299 | /** 300 | * Since 9 301 | * Moves and resizes the embedded frame. The new location of the top-left 302 | * corner is specified by x and y parameters relative to the native parent 303 | * component. The new size is specified by width and height. 304 | * 305 | * The embedded frame should be created by CreateEmbeddedFrame() method, or 306 | * this function will not have any effect. 307 | * 308 | * java.awt.Component.setLocation() and java.awt.Component.setBounds() for 309 | * EmbeddedFrame really don't move it within the native parent. These 310 | * methods always locate the embedded frame at (0, 0) for backward 311 | * compatibility. To allow moving embedded frames this method was 312 | * introduced, and it works just the same way as setLocation() and 313 | * setBounds() for usual, non-embedded components. 314 | * 315 | * Using usual get/setLocation() and get/setBounds() together with this new 316 | * method is not recommended. 317 | */ 318 | void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame, 319 | jint x, jint y, jint w, jint h); 320 | /** 321 | * Since 9 322 | * Synthesize a native message to activate or deactivate an EmbeddedFrame 323 | * window depending on the value of parameter doActivate, if "true" 324 | * activates the window; otherwise, deactivates the window. 325 | * 326 | * The embedded frame should be created by CreateEmbeddedFrame() method, or 327 | * this function will not have any effect. 328 | */ 329 | void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env, 330 | jobject embeddedFrame, jboolean doActivate); 331 | } JAWT; 332 | 333 | /* 334 | * Get the AWT native structure. This function returns JNI_FALSE if 335 | * an error occurs. 336 | */ 337 | _JNI_IMPORT_OR_EXPORT_ 338 | jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); 339 | 340 | /* 341 | * Specify one of these constants as the JAWT.version 342 | * Specifying an earlier version will limit the available functions to 343 | * those provided in that earlier version of JAWT. 344 | * See the "Since" note on each API. Methods with no "Since" 345 | * may be presumed to be present in JAWT_VERSION_1_3. 346 | */ 347 | #define JAWT_VERSION_1_3 0x00010003 348 | #define JAWT_VERSION_1_4 0x00010004 349 | #define JAWT_VERSION_1_7 0x00010007 350 | #define JAWT_VERSION_9 0x00090000 351 | 352 | #ifdef __cplusplus 353 | } /* extern "C" */ 354 | #endif 355 | 356 | #endif /* !_JAVASOFT_JAWT_H_ */ 357 | -------------------------------------------------------------------------------- /include/jawt_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVASOFT_JAWT_MD_H_ 27 | #define _JAVASOFT_JAWT_MD_H_ 28 | 29 | #include 30 | #include 31 | #include "jawt.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* 38 | * X11-specific declarations for AWT native interface. 39 | * See notes in jawt.h for an example of use. 40 | */ 41 | typedef struct jawt_X11DrawingSurfaceInfo { 42 | Drawable drawable; 43 | Display* display; 44 | VisualID visualID; 45 | Colormap colormapID; 46 | int depth; 47 | /* 48 | * Since 1.4 49 | * Returns a pixel value from a set of RGB values. 50 | * This is useful for paletted color (256 color) modes. 51 | */ 52 | int (JNICALL *GetAWTColor)(JAWT_DrawingSurface* ds, 53 | int r, int g, int b); 54 | } JAWT_X11DrawingSurfaceInfo; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* !_JAVASOFT_JAWT_MD_H_ */ 61 | -------------------------------------------------------------------------------- /include/jdwpTransport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | /* 27 | * Java Debug Wire Protocol Transport Service Provider Interface. 28 | */ 29 | 30 | #ifndef JDWPTRANSPORT_H 31 | #define JDWPTRANSPORT_H 32 | 33 | #include "jni.h" 34 | 35 | enum { 36 | JDWPTRANSPORT_VERSION_1_0 = 0x00010000, 37 | JDWPTRANSPORT_VERSION_1_1 = 0x00010001 38 | }; 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | struct jdwpTransportNativeInterface_; 45 | 46 | struct _jdwpTransportEnv; 47 | 48 | #ifdef __cplusplus 49 | typedef _jdwpTransportEnv jdwpTransportEnv; 50 | #else 51 | typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; 52 | #endif /* __cplusplus */ 53 | 54 | /* 55 | * Errors. Universal errors with JVMTI/JVMDI equivalents keep the 56 | * values the same. 57 | */ 58 | typedef enum { 59 | JDWPTRANSPORT_ERROR_NONE = 0, 60 | JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, 61 | JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, 62 | JDWPTRANSPORT_ERROR_INTERNAL = 113, 63 | JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, 64 | JDWPTRANSPORT_ERROR_IO_ERROR = 202, 65 | JDWPTRANSPORT_ERROR_TIMEOUT = 203, 66 | JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204 67 | } jdwpTransportError; 68 | 69 | 70 | /* 71 | * Structure to define capabilities 72 | */ 73 | typedef struct { 74 | unsigned int can_timeout_attach :1; 75 | unsigned int can_timeout_accept :1; 76 | unsigned int can_timeout_handshake :1; 77 | unsigned int reserved3 :1; 78 | unsigned int reserved4 :1; 79 | unsigned int reserved5 :1; 80 | unsigned int reserved6 :1; 81 | unsigned int reserved7 :1; 82 | unsigned int reserved8 :1; 83 | unsigned int reserved9 :1; 84 | unsigned int reserved10 :1; 85 | unsigned int reserved11 :1; 86 | unsigned int reserved12 :1; 87 | unsigned int reserved13 :1; 88 | unsigned int reserved14 :1; 89 | unsigned int reserved15 :1; 90 | } JDWPTransportCapabilities; 91 | 92 | 93 | /* 94 | * Structures to define packet layout. 95 | * 96 | * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html 97 | */ 98 | 99 | #define JDWP_HEADER_SIZE 11 100 | 101 | enum { 102 | /* 103 | * If additional flags are added that apply to jdwpCmdPacket, 104 | * then debugLoop.c: reader() will need to be updated to 105 | * accept more than JDWPTRANSPORT_FLAGS_NONE. 106 | */ 107 | JDWPTRANSPORT_FLAGS_NONE = 0x0, 108 | JDWPTRANSPORT_FLAGS_REPLY = 0x80 109 | }; 110 | 111 | typedef struct { 112 | jint len; 113 | jint id; 114 | jbyte flags; 115 | jbyte cmdSet; 116 | jbyte cmd; 117 | jbyte *data; 118 | } jdwpCmdPacket; 119 | 120 | typedef struct { 121 | jint len; 122 | jint id; 123 | jbyte flags; 124 | jshort errorCode; 125 | jbyte *data; 126 | } jdwpReplyPacket; 127 | 128 | typedef struct { 129 | union { 130 | jdwpCmdPacket cmd; 131 | jdwpReplyPacket reply; 132 | } type; 133 | } jdwpPacket; 134 | 135 | /* 136 | * JDWP functions called by the transport. 137 | */ 138 | typedef struct jdwpTransportCallback { 139 | void *(*alloc)(jint numBytes); /* Call this for all allocations */ 140 | void (*free)(void *buffer); /* Call this for all deallocations */ 141 | } jdwpTransportCallback; 142 | 143 | typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, 144 | jdwpTransportCallback *callback, 145 | jint version, 146 | jdwpTransportEnv** env); 147 | 148 | /* 149 | * JDWP transport configuration from the agent. 150 | */ 151 | typedef struct jdwpTransportConfiguration { 152 | /* Field added in JDWPTRANSPORT_VERSION_1_1: */ 153 | const char* allowed_peers; /* Peers allowed for connection */ 154 | } jdwpTransportConfiguration; 155 | 156 | 157 | /* Function Interface */ 158 | 159 | struct jdwpTransportNativeInterface_ { 160 | /* 1 : RESERVED */ 161 | void *reserved1; 162 | 163 | /* 2 : Get Capabilities */ 164 | jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, 165 | JDWPTransportCapabilities *capabilities_ptr); 166 | 167 | /* 3 : Attach */ 168 | jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, 169 | const char* address, 170 | jlong attach_timeout, 171 | jlong handshake_timeout); 172 | 173 | /* 4: StartListening */ 174 | jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, 175 | const char* address, 176 | char** actual_address); 177 | 178 | /* 5: StopListening */ 179 | jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); 180 | 181 | /* 6: Accept */ 182 | jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, 183 | jlong accept_timeout, 184 | jlong handshake_timeout); 185 | 186 | /* 7: IsOpen */ 187 | jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); 188 | 189 | /* 8: Close */ 190 | jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); 191 | 192 | /* 9: ReadPacket */ 193 | jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, 194 | jdwpPacket *pkt); 195 | 196 | /* 10: Write Packet */ 197 | jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, 198 | const jdwpPacket* pkt); 199 | 200 | /* 11: GetLastError */ 201 | jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, 202 | char** error); 203 | 204 | /* 12: SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */ 205 | jdwpTransportError (JNICALL *SetTransportConfiguration)(jdwpTransportEnv* env, 206 | jdwpTransportConfiguration *config); 207 | }; 208 | 209 | 210 | /* 211 | * Use inlined functions so that C++ code can use syntax such as 212 | * env->Attach("mymachine:5000", 10*1000, 0); 213 | * 214 | * rather than using C's :- 215 | * 216 | * (*env)->Attach(env, "mymachine:5000", 10*1000, 0); 217 | */ 218 | struct _jdwpTransportEnv { 219 | const struct jdwpTransportNativeInterface_ *functions; 220 | #ifdef __cplusplus 221 | 222 | jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) { 223 | return functions->GetCapabilities(this, capabilities_ptr); 224 | } 225 | 226 | jdwpTransportError Attach(const char* address, jlong attach_timeout, 227 | jlong handshake_timeout) { 228 | return functions->Attach(this, address, attach_timeout, handshake_timeout); 229 | } 230 | 231 | jdwpTransportError StartListening(const char* address, 232 | char** actual_address) { 233 | return functions->StartListening(this, address, actual_address); 234 | } 235 | 236 | jdwpTransportError StopListening(void) { 237 | return functions->StopListening(this); 238 | } 239 | 240 | jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) { 241 | return functions->Accept(this, accept_timeout, handshake_timeout); 242 | } 243 | 244 | jboolean IsOpen(void) { 245 | return functions->IsOpen(this); 246 | } 247 | 248 | jdwpTransportError Close(void) { 249 | return functions->Close(this); 250 | } 251 | 252 | jdwpTransportError ReadPacket(jdwpPacket *pkt) { 253 | return functions->ReadPacket(this, pkt); 254 | } 255 | 256 | jdwpTransportError WritePacket(const jdwpPacket* pkt) { 257 | return functions->WritePacket(this, pkt); 258 | } 259 | 260 | jdwpTransportError GetLastError(char** error) { 261 | return functions->GetLastError(this, error); 262 | } 263 | 264 | /* SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */ 265 | jdwpTransportError SetTransportConfiguration(jdwpTransportEnv* env, 266 | return functions->SetTransportConfiguration(this, config); 267 | } 268 | 269 | #endif /* __cplusplus */ 270 | }; 271 | 272 | #ifdef __cplusplus 273 | } /* extern "C" */ 274 | #endif /* __cplusplus */ 275 | 276 | #endif /* JDWPTRANSPORT_H */ 277 | -------------------------------------------------------------------------------- /include/jmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVA_JMM_H_ 27 | #define _JAVA_JMM_H_ 28 | 29 | /* 30 | * This is a private interface used by JDK for JVM monitoring 31 | * and management. 32 | * 33 | * Bump the version number when either of the following happens: 34 | * 35 | * 1. There is a change in functions in JmmInterface. 36 | * 37 | * 2. There is a change in the contract between VM and Java classes. 38 | */ 39 | 40 | #include "jni.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | enum { 47 | JMM_VERSION_1 = 0x20010000, 48 | JMM_VERSION_1_0 = 0x20010000, 49 | JMM_VERSION_1_1 = 0x20010100, // JDK 6 50 | JMM_VERSION_1_2 = 0x20010200, // JDK 7 51 | JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA 52 | JMM_VERSION_1_2_2 = 0x20010202, 53 | JMM_VERSION_2 = 0x20020000, // JDK 10 54 | JMM_VERSION_3 = 0x20030000, // JDK 14 55 | JMM_VERSION = JMM_VERSION_3 56 | }; 57 | 58 | typedef struct { 59 | unsigned int isLowMemoryDetectionSupported : 1; 60 | unsigned int isCompilationTimeMonitoringSupported : 1; 61 | unsigned int isThreadContentionMonitoringSupported : 1; 62 | unsigned int isCurrentThreadCpuTimeSupported : 1; 63 | unsigned int isOtherThreadCpuTimeSupported : 1; 64 | unsigned int isObjectMonitorUsageSupported : 1; 65 | unsigned int isSynchronizerUsageSupported : 1; 66 | unsigned int isThreadAllocatedMemorySupported : 1; 67 | unsigned int isRemoteDiagnosticCommandsSupported : 1; 68 | unsigned int : 22; 69 | } jmmOptionalSupport; 70 | 71 | typedef enum { 72 | JMM_CLASS_LOADED_COUNT = 1, /* Total number of loaded classes */ 73 | JMM_CLASS_UNLOADED_COUNT = 2, /* Total number of unloaded classes */ 74 | JMM_THREAD_TOTAL_COUNT = 3, /* Total number of threads that have been started */ 75 | JMM_THREAD_LIVE_COUNT = 4, /* Current number of live threads */ 76 | JMM_THREAD_PEAK_COUNT = 5, /* Peak number of live threads */ 77 | JMM_THREAD_DAEMON_COUNT = 6, /* Current number of daemon threads */ 78 | JMM_JVM_INIT_DONE_TIME_MS = 7, /* Time when the JVM finished initialization */ 79 | JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */ 80 | JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */ 81 | JMM_GC_COUNT = 10, /* Total number of collections */ 82 | JMM_JVM_UPTIME_MS = 11, /* The JVM uptime in milliseconds */ 83 | 84 | JMM_INTERNAL_ATTRIBUTE_INDEX = 100, 85 | JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */ 86 | JMM_CLASS_UNLOADED_BYTES = 102, /* Number of bytes unloaded instance classes */ 87 | JMM_TOTAL_CLASSLOAD_TIME_MS = 103, /* Accumulated VM class loader time (TraceClassLoadingTime) */ 88 | JMM_VM_GLOBAL_COUNT = 104, /* Number of VM internal flags */ 89 | JMM_SAFEPOINT_COUNT = 105, /* Total number of safepoints */ 90 | JMM_TOTAL_SAFEPOINTSYNC_TIME_MS = 106, /* Accumulated time spent getting to safepoints */ 91 | JMM_TOTAL_STOPPED_TIME_MS = 107, /* Accumulated time spent at safepoints */ 92 | JMM_TOTAL_APP_TIME_MS = 108, /* Accumulated time spent in Java application */ 93 | JMM_VM_THREAD_COUNT = 109, /* Current number of VM internal threads */ 94 | JMM_CLASS_INIT_TOTAL_COUNT = 110, /* Number of classes for which initializers were run */ 95 | JMM_CLASS_INIT_TOTAL_TIME_MS = 111, /* Accumulated time spent in class initializers */ 96 | JMM_METHOD_DATA_SIZE_BYTES = 112, /* Size of method data in memory */ 97 | JMM_CLASS_VERIFY_TOTAL_TIME_MS = 113, /* Accumulated time spent in class verifier */ 98 | JMM_SHARED_CLASS_LOADED_COUNT = 114, /* Number of shared classes loaded */ 99 | JMM_SHARED_CLASS_UNLOADED_COUNT = 115, /* Number of shared classes unloaded */ 100 | JMM_SHARED_CLASS_LOADED_BYTES = 116, /* Number of bytes loaded shared classes */ 101 | JMM_SHARED_CLASS_UNLOADED_BYTES = 117, /* Number of bytes unloaded shared classes */ 102 | 103 | JMM_OS_ATTRIBUTE_INDEX = 200, 104 | JMM_OS_PROCESS_ID = 201, /* Process id of the JVM */ 105 | JMM_OS_MEM_TOTAL_PHYSICAL_BYTES = 202, /* Physical memory size */ 106 | 107 | JMM_GC_EXT_ATTRIBUTE_INFO_SIZE = 401 /* the size of the GC specific attributes for a given GC memory manager */ 108 | } jmmLongAttribute; 109 | 110 | typedef enum { 111 | JMM_VERBOSE_GC = 21, 112 | JMM_VERBOSE_CLASS = 22, 113 | JMM_THREAD_CONTENTION_MONITORING = 23, 114 | JMM_THREAD_CPU_TIME = 24, 115 | JMM_THREAD_ALLOCATED_MEMORY = 25 116 | } jmmBoolAttribute; 117 | 118 | 119 | enum { 120 | JMM_THREAD_STATE_FLAG_SUSPENDED = 0x00100000, 121 | JMM_THREAD_STATE_FLAG_NATIVE = 0x00400000 122 | }; 123 | 124 | #define JMM_THREAD_STATE_FLAG_MASK 0xFFF00000 125 | 126 | typedef enum { 127 | JMM_STAT_PEAK_THREAD_COUNT = 801, 128 | JMM_STAT_THREAD_CONTENTION_COUNT = 802, 129 | JMM_STAT_THREAD_CONTENTION_TIME = 803, 130 | JMM_STAT_THREAD_CONTENTION_STAT = 804, 131 | JMM_STAT_PEAK_POOL_USAGE = 805, 132 | JMM_STAT_GC_STAT = 806 133 | } jmmStatisticType; 134 | 135 | typedef enum { 136 | JMM_USAGE_THRESHOLD_HIGH = 901, 137 | JMM_USAGE_THRESHOLD_LOW = 902, 138 | JMM_COLLECTION_USAGE_THRESHOLD_HIGH = 903, 139 | JMM_COLLECTION_USAGE_THRESHOLD_LOW = 904 140 | } jmmThresholdType; 141 | 142 | /* Should match what is allowed in globals.hpp */ 143 | typedef enum { 144 | JMM_VMGLOBAL_TYPE_UNKNOWN = 0, 145 | JMM_VMGLOBAL_TYPE_JBOOLEAN = 1, 146 | JMM_VMGLOBAL_TYPE_JSTRING = 2, 147 | JMM_VMGLOBAL_TYPE_JLONG = 3, 148 | JMM_VMGLOBAL_TYPE_JDOUBLE = 4 149 | } jmmVMGlobalType; 150 | 151 | typedef enum { 152 | JMM_VMGLOBAL_ORIGIN_DEFAULT = 1, /* Default value */ 153 | JMM_VMGLOBAL_ORIGIN_COMMAND_LINE = 2, /* Set at command line (or JNI invocation) */ 154 | JMM_VMGLOBAL_ORIGIN_MANAGEMENT = 3, /* Set via management interface */ 155 | JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */ 156 | JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */ 157 | JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */ 158 | JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND = 7, /* Set via attach */ 159 | JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */ 160 | } jmmVMGlobalOrigin; 161 | 162 | typedef struct { 163 | jstring name; 164 | jvalue value; 165 | jmmVMGlobalType type; /* Data type */ 166 | jmmVMGlobalOrigin origin; /* Default or non-default value */ 167 | unsigned int writeable : 1; /* dynamically writeable */ 168 | unsigned int external : 1; /* external supported interface */ 169 | unsigned int reserved : 30; 170 | void *reserved1; 171 | void *reserved2; 172 | } jmmVMGlobal; 173 | 174 | typedef struct { 175 | const char* name; 176 | char type; 177 | const char* description; 178 | } jmmExtAttributeInfo; 179 | 180 | /* Caller has to set the following fields before calling GetLastGCStat 181 | * o usage_before_gc - array of MemoryUsage objects 182 | * o usage_after_gc - array of MemoryUsage objects 183 | * o gc_ext_attribute_values_size - size of gc_ext_atttribute_values array 184 | * o gc_ext_attribtue_values - array of jvalues 185 | */ 186 | typedef struct { 187 | jlong gc_index; /* Index of the collections */ 188 | jlong start_time; /* Start time of the GC */ 189 | jlong end_time; /* End time of the GC */ 190 | jobjectArray usage_before_gc; /* Memory usage array before GC */ 191 | jobjectArray usage_after_gc; /* Memory usage array after GC */ 192 | jint gc_ext_attribute_values_size; /* set by the caller of GetGCStat */ 193 | jvalue* gc_ext_attribute_values; /* Array of jvalue for GC extension attributes */ 194 | jint num_gc_ext_attributes; /* number of GC extension attribute values s are filled */ 195 | /* -1 indicates gc_ext_attribute_values is not big enough */ 196 | } jmmGCStat; 197 | 198 | typedef struct { 199 | const char* name; /* Name of the diagnostic command */ 200 | const char* description; /* Short description */ 201 | const char* impact; /* Impact on the JVM */ 202 | const char* permission_class; /* Class name of the required permission if any */ 203 | const char* permission_name; /* Permission name of the required permission if any */ 204 | const char* permission_action; /* Action name of the required permission if any*/ 205 | int num_arguments; /* Number of supported options or arguments */ 206 | jboolean enabled; /* True if the diagnostic command can be invoked, false otherwise*/ 207 | } dcmdInfo; 208 | 209 | typedef struct { 210 | const char* name; /* Option/Argument name*/ 211 | const char* description; /* Short description */ 212 | const char* type; /* Type: STRING, BOOLEAN, etc. */ 213 | const char* default_string; /* Default value in a parsable string */ 214 | jboolean mandatory; /* True if the option/argument is mandatory */ 215 | jboolean option; /* True if it is an option, false if it is an argument */ 216 | /* (see diagnosticFramework.hpp for option/argument definitions) */ 217 | jboolean multiple; /* True is the option can be specified several time */ 218 | int position; /* Expected position for this argument (this field is */ 219 | /* meaningless for options) */ 220 | } dcmdArgInfo; 221 | 222 | typedef struct jmmInterface_1_ { 223 | void* reserved1; 224 | void* reserved2; 225 | 226 | jint (JNICALL *GetVersion) (JNIEnv *env); 227 | 228 | jint (JNICALL *GetOptionalSupport) (JNIEnv *env, 229 | jmmOptionalSupport* support_ptr); 230 | 231 | jint (JNICALL *GetThreadInfo) (JNIEnv *env, 232 | jlongArray ids, 233 | jint maxDepth, 234 | jobjectArray infoArray); 235 | 236 | jobjectArray (JNICALL *GetMemoryPools) (JNIEnv* env, jobject mgr); 237 | 238 | jobjectArray (JNICALL *GetMemoryManagers) (JNIEnv* env, jobject pool); 239 | 240 | jobject (JNICALL *GetMemoryPoolUsage) (JNIEnv* env, jobject pool); 241 | jobject (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool); 242 | 243 | jlong (JNICALL *GetOneThreadAllocatedMemory) 244 | (JNIEnv *env, 245 | jlong thread_id); 246 | void (JNICALL *GetThreadAllocatedMemory) 247 | (JNIEnv *env, 248 | jlongArray ids, 249 | jlongArray sizeArray); 250 | 251 | jobject (JNICALL *GetMemoryUsage) (JNIEnv* env, jboolean heap); 252 | 253 | jlong (JNICALL *GetLongAttribute) (JNIEnv *env, jobject obj, jmmLongAttribute att); 254 | jboolean (JNICALL *GetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att); 255 | jboolean (JNICALL *SetBoolAttribute) (JNIEnv *env, jmmBoolAttribute att, jboolean flag); 256 | 257 | jint (JNICALL *GetLongAttributes) (JNIEnv *env, 258 | jobject obj, 259 | jmmLongAttribute* atts, 260 | jint count, 261 | jlong* result); 262 | 263 | jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env); 264 | 265 | // Not used in JDK 6 or JDK 7 266 | jlong (JNICALL *GetThreadCpuTime) (JNIEnv *env, jlong thread_id); 267 | 268 | jobjectArray (JNICALL *GetVMGlobalNames) (JNIEnv *env); 269 | jint (JNICALL *GetVMGlobals) (JNIEnv *env, 270 | jobjectArray names, 271 | jmmVMGlobal *globals, 272 | jint count); 273 | 274 | jint (JNICALL *GetInternalThreadTimes) (JNIEnv *env, 275 | jobjectArray names, 276 | jlongArray times); 277 | 278 | jboolean (JNICALL *ResetStatistic) (JNIEnv *env, 279 | jvalue obj, 280 | jmmStatisticType type); 281 | 282 | void (JNICALL *SetPoolSensor) (JNIEnv *env, 283 | jobject pool, 284 | jmmThresholdType type, 285 | jobject sensor); 286 | 287 | jlong (JNICALL *SetPoolThreshold) (JNIEnv *env, 288 | jobject pool, 289 | jmmThresholdType type, 290 | jlong threshold); 291 | jobject (JNICALL *GetPoolCollectionUsage) (JNIEnv* env, jobject pool); 292 | 293 | jint (JNICALL *GetGCExtAttributeInfo) (JNIEnv *env, 294 | jobject mgr, 295 | jmmExtAttributeInfo *ext_info, 296 | jint count); 297 | void (JNICALL *GetLastGCStat) (JNIEnv *env, 298 | jobject mgr, 299 | jmmGCStat *gc_stat); 300 | 301 | jlong (JNICALL *GetThreadCpuTimeWithKind) 302 | (JNIEnv *env, 303 | jlong thread_id, 304 | jboolean user_sys_cpu_time); 305 | void (JNICALL *GetThreadCpuTimesWithKind) 306 | (JNIEnv *env, 307 | jlongArray ids, 308 | jlongArray timeArray, 309 | jboolean user_sys_cpu_time); 310 | 311 | jint (JNICALL *DumpHeap0) (JNIEnv *env, 312 | jstring outputfile, 313 | jboolean live); 314 | jobjectArray (JNICALL *FindDeadlocks) (JNIEnv *env, 315 | jboolean object_monitors_only); 316 | void (JNICALL *SetVMGlobal) (JNIEnv *env, 317 | jstring flag_name, 318 | jvalue new_value); 319 | void* reserved6; 320 | jobjectArray (JNICALL *DumpThreads) (JNIEnv *env, 321 | jlongArray ids, 322 | jboolean lockedMonitors, 323 | jboolean lockedSynchronizers, 324 | jint maxDepth); 325 | void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env, 326 | jobject mgr, 327 | jboolean enabled); 328 | jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env); 329 | void (JNICALL *GetDiagnosticCommandInfo) 330 | (JNIEnv *env, 331 | jobjectArray cmds, 332 | dcmdInfo *infoArray); 333 | void (JNICALL *GetDiagnosticCommandArgumentsInfo) 334 | (JNIEnv *env, 335 | jstring commandName, 336 | dcmdArgInfo *infoArray); 337 | jstring (JNICALL *ExecuteDiagnosticCommand) 338 | (JNIEnv *env, 339 | jstring command); 340 | void (JNICALL *SetDiagnosticFrameworkNotificationEnabled) 341 | (JNIEnv *env, 342 | jboolean enabled); 343 | } JmmInterface; 344 | 345 | #ifdef __cplusplus 346 | } /* extern "C" */ 347 | #endif /* __cplusplus */ 348 | 349 | #endif /* !_JAVA_JMM_H_ */ 350 | -------------------------------------------------------------------------------- /include/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVASOFT_JNI_MD_H_ 27 | #define _JAVASOFT_JNI_MD_H_ 28 | 29 | #ifndef __has_attribute 30 | #define __has_attribute(x) 0 31 | #endif 32 | 33 | #ifndef JNIEXPORT 34 | #if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) 35 | #ifdef ARM 36 | #define JNIEXPORT __attribute__((externally_visible,visibility("default"))) 37 | #else 38 | #define JNIEXPORT __attribute__((visibility("default"))) 39 | #endif 40 | #else 41 | #define JNIEXPORT 42 | #endif 43 | #endif 44 | 45 | #if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) 46 | #ifdef ARM 47 | #define JNIIMPORT __attribute__((externally_visible,visibility("default"))) 48 | #else 49 | #define JNIIMPORT __attribute__((visibility("default"))) 50 | #endif 51 | #else 52 | #define JNIIMPORT 53 | #endif 54 | 55 | #define JNICALL 56 | 57 | typedef int jint; 58 | #ifdef _LP64 59 | typedef long jlong; 60 | #else 61 | typedef long long jlong; 62 | #endif 63 | 64 | typedef signed char jbyte; 65 | 66 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 67 | -------------------------------------------------------------------------------- /include/jvm_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | #ifndef _JAVASOFT_JVM_MD_H_ 27 | #define _JAVASOFT_JVM_MD_H_ 28 | 29 | /* 30 | * This file is currently collecting system-specific dregs for the 31 | * JNI conversion, which should be sorted out later. 32 | */ 33 | 34 | #include /* For DIR */ 35 | #include /* For MAXPATHLEN */ 36 | #include /* For F_OK, R_OK, W_OK */ 37 | #include /* For ptrdiff_t */ 38 | #include /* For uintptr_t */ 39 | 40 | #define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"} 41 | #define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"} 42 | #define JVM_ONLOAD_SYMBOLS {"JVM_OnLoad"} 43 | #define AGENT_ONLOAD_SYMBOLS {"Agent_OnLoad"} 44 | #define AGENT_ONUNLOAD_SYMBOLS {"Agent_OnUnload"} 45 | #define AGENT_ONATTACH_SYMBOLS {"Agent_OnAttach"} 46 | 47 | #define JNI_LIB_PREFIX "lib" 48 | #ifdef __APPLE__ 49 | #define JNI_LIB_SUFFIX ".dylib" 50 | #define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME "." VERSION JNI_LIB_SUFFIX 51 | #else 52 | #define JNI_LIB_SUFFIX ".so" 53 | #define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX "." VERSION 54 | #endif 55 | #define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX 56 | 57 | #if defined(AIX) 58 | #define JVM_MAXPATHLEN MAXPATHLEN 59 | #else 60 | // Hack: MAXPATHLEN is 4095 on some Linux and 4096 on others. This may 61 | // cause problems if JVM and the rest of JDK are built on different 62 | // Linux releases. Here we define JVM_MAXPATHLEN to be MAXPATHLEN + 1, 63 | // so buffers declared in VM are always >= 4096. 64 | #define JVM_MAXPATHLEN MAXPATHLEN + 1 65 | #endif 66 | 67 | #define JVM_R_OK R_OK 68 | #define JVM_W_OK W_OK 69 | #define JVM_X_OK X_OK 70 | #define JVM_F_OK F_OK 71 | 72 | /* 73 | * File I/O 74 | */ 75 | 76 | #include 77 | #include 78 | #include 79 | #include 80 | #include 81 | 82 | /* Signals */ 83 | 84 | #include // for socklen_t 85 | 86 | #define JVM_SIGINT SIGINT 87 | #define JVM_SIGTERM SIGTERM 88 | 89 | #define BREAK_SIGNAL SIGQUIT /* Thread dumping support. */ 90 | #define SHUTDOWN1_SIGNAL SIGHUP /* Shutdown Hooks support. */ 91 | #define SHUTDOWN2_SIGNAL SIGINT 92 | #define SHUTDOWN3_SIGNAL SIGTERM 93 | 94 | #endif /* !_JAVASOFT_JVM_MD_H_ */ 95 | -------------------------------------------------------------------------------- /include/jvmticmlr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 | * 5 | * This code is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 only, as 7 | * published by the Free Software Foundation. Oracle designates this 8 | * particular file as subject to the "Classpath" exception as provided 9 | * by Oracle in the LICENSE file that accompanied this code. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 | * or visit www.oracle.com if you need additional information or have any 23 | * questions. 24 | */ 25 | 26 | /* 27 | * This header file defines the data structures sent by the VM 28 | * through the JVMTI CompiledMethodLoad callback function via the 29 | * "void * compile_info" parameter. The memory pointed to by the 30 | * compile_info parameter may not be referenced after returning from 31 | * the CompiledMethodLoad callback. These are VM implementation 32 | * specific data structures that may evolve in future releases. A 33 | * JVMTI agent should interpret a non-NULL compile_info as a pointer 34 | * to a region of memory containing a list of records. In a typical 35 | * usage scenario, a JVMTI agent would cast each record to a 36 | * jvmtiCompiledMethodLoadRecordHeader, a struct that represents 37 | * arbitrary information. This struct contains a kind field to indicate 38 | * the kind of information being passed, and a pointer to the next 39 | * record. If the kind field indicates inlining information, then the 40 | * agent would cast the record to a jvmtiCompiledMethodLoadInlineRecord. 41 | * This record contains an array of PCStackInfo structs, which indicate 42 | * for every pc address what are the methods on the invocation stack. 43 | * The "methods" and "bcis" fields in each PCStackInfo struct specify a 44 | * 1-1 mapping between these inlined methods and their bytecode indices. 45 | * This can be used to derive the proper source lines of the inlined 46 | * methods. 47 | */ 48 | 49 | /* 50 | * Added to allow bindgen to work 51 | */ 52 | #include "jni.h" 53 | 54 | #ifndef _JVMTI_CMLR_H_ 55 | #define _JVMTI_CMLR_H_ 56 | 57 | enum { 58 | JVMTI_CMLR_MAJOR_VERSION_1 = 0x00000001, 59 | JVMTI_CMLR_MINOR_VERSION_0 = 0x00000000, 60 | 61 | JVMTI_CMLR_MAJOR_VERSION = 0x00000001, 62 | JVMTI_CMLR_MINOR_VERSION = 0x00000000 63 | 64 | /* 65 | * This comment is for the "JDK import from HotSpot" sanity check: 66 | * version: 1.0.0 67 | */ 68 | }; 69 | 70 | typedef enum { 71 | JVMTI_CMLR_DUMMY = 1, 72 | JVMTI_CMLR_INLINE_INFO = 2 73 | } jvmtiCMLRKind; 74 | 75 | /* 76 | * Record that represents arbitrary information passed through JVMTI 77 | * CompiledMethodLoadEvent void pointer. 78 | */ 79 | typedef struct _jvmtiCompiledMethodLoadRecordHeader { 80 | jvmtiCMLRKind kind; /* id for the kind of info passed in the record */ 81 | jint majorinfoversion; /* major and minor info version values. Init'ed */ 82 | jint minorinfoversion; /* to current version value in jvmtiExport.cpp. */ 83 | 84 | struct _jvmtiCompiledMethodLoadRecordHeader* next; 85 | } jvmtiCompiledMethodLoadRecordHeader; 86 | 87 | /* 88 | * Record that gives information about the methods on the compile-time 89 | * stack at a specific pc address of a compiled method. Each element in 90 | * the methods array maps to same element in the bcis array. 91 | */ 92 | typedef struct _PCStackInfo { 93 | void* pc; /* the pc address for this compiled method */ 94 | jint numstackframes; /* number of methods on the stack */ 95 | jmethodID* methods; /* array of numstackframes method ids */ 96 | jint* bcis; /* array of numstackframes bytecode indices */ 97 | } PCStackInfo; 98 | 99 | /* 100 | * Record that contains inlining information for each pc address of 101 | * an nmethod. 102 | */ 103 | typedef struct _jvmtiCompiledMethodLoadInlineRecord { 104 | jvmtiCompiledMethodLoadRecordHeader header; /* common header for casting */ 105 | jint numpcs; /* number of pc descriptors in this nmethod */ 106 | PCStackInfo* pcinfo; /* array of numpcs pc descriptors */ 107 | } jvmtiCompiledMethodLoadInlineRecord; 108 | 109 | /* 110 | * Dummy record used to test that we can pass records with different 111 | * information through the void pointer provided that they can be cast 112 | * to a jvmtiCompiledMethodLoadRecordHeader. 113 | */ 114 | 115 | typedef struct _jvmtiCompiledMethodLoadDummyRecord { 116 | jvmtiCompiledMethodLoadRecordHeader header; /* common header for casting */ 117 | char message[50]; 118 | } jvmtiCompiledMethodLoadDummyRecord; 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /src/bitfield.rs: -------------------------------------------------------------------------------- 1 | #[repr(C)] 2 | #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] 3 | pub struct __BindgenBitfieldUnit { 4 | storage: Storage, 5 | align: [Align; 0], 6 | } 7 | impl __BindgenBitfieldUnit { 8 | #[inline] 9 | pub const fn new(storage: Storage) -> Self { 10 | Self { storage, align: [] } 11 | } 12 | } 13 | impl __BindgenBitfieldUnit 14 | where 15 | Storage: AsRef<[u8]> + AsMut<[u8]>, 16 | { 17 | #[inline] 18 | pub fn get_bit(&self, index: usize) -> bool { 19 | debug_assert!(index / 8 < self.storage.as_ref().len()); 20 | let byte_index = index / 8; 21 | let byte = self.storage.as_ref()[byte_index]; 22 | let bit_index = if cfg!(target_endian = "big") { 23 | 7 - (index % 8) 24 | } else { 25 | index % 8 26 | }; 27 | let mask = 1 << bit_index; 28 | byte & mask == mask 29 | } 30 | #[inline] 31 | pub fn set_bit(&mut self, index: usize, val: bool) { 32 | debug_assert!(index / 8 < self.storage.as_ref().len()); 33 | let byte_index = index / 8; 34 | let byte = &mut self.storage.as_mut()[byte_index]; 35 | let bit_index = if cfg!(target_endian = "big") { 36 | 7 - (index % 8) 37 | } else { 38 | index % 8 39 | }; 40 | let mask = 1 << bit_index; 41 | if val { 42 | *byte |= mask; 43 | } else { 44 | *byte &= !mask; 45 | } 46 | } 47 | #[inline] 48 | pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { 49 | debug_assert!(bit_width <= 64); 50 | debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); 51 | debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); 52 | let mut val = 0; 53 | for i in 0..(bit_width as usize) { 54 | if self.get_bit(i + bit_offset) { 55 | let index = if cfg!(target_endian = "big") { 56 | bit_width as usize - 1 - i 57 | } else { 58 | i 59 | }; 60 | val |= 1 << index; 61 | } 62 | } 63 | val 64 | } 65 | #[inline] 66 | pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { 67 | debug_assert!(bit_width <= 64); 68 | debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); 69 | debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); 70 | for i in 0..(bit_width as usize) { 71 | let mask = 1 << i; 72 | let val_bit_is_set = val & mask == mask; 73 | let index = if cfg!(target_endian = "big") { 74 | bit_width as usize - 1 - i 75 | } else { 76 | i 77 | }; 78 | self.set_bit(index + bit_offset, val_bit_is_set); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/classfile_constants.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(dead_code)] 5 | 6 | pub const JVM_CLASSFILE_MAJOR_VERSION: u32 = 59; 7 | pub const JVM_CLASSFILE_MINOR_VERSION: u32 = 0; 8 | pub const JVM_ACC_PUBLIC_BIT: u32 = 0; 9 | pub const JVM_ACC_PRIVATE_BIT: u32 = 1; 10 | pub const JVM_ACC_PROTECTED_BIT: u32 = 2; 11 | pub const JVM_ACC_STATIC_BIT: u32 = 3; 12 | pub const JVM_ACC_FINAL_BIT: u32 = 4; 13 | pub const JVM_ACC_SYNCHRONIZED_BIT: u32 = 5; 14 | pub const JVM_ACC_SUPER_BIT: u32 = 5; 15 | pub const JVM_ACC_VOLATILE_BIT: u32 = 6; 16 | pub const JVM_ACC_BRIDGE_BIT: u32 = 6; 17 | pub const JVM_ACC_TRANSIENT_BIT: u32 = 7; 18 | pub const JVM_ACC_VARARGS_BIT: u32 = 7; 19 | pub const JVM_ACC_NATIVE_BIT: u32 = 8; 20 | pub const JVM_ACC_INTERFACE_BIT: u32 = 9; 21 | pub const JVM_ACC_ABSTRACT_BIT: u32 = 10; 22 | pub const JVM_ACC_STRICT_BIT: u32 = 11; 23 | pub const JVM_ACC_SYNTHETIC_BIT: u32 = 12; 24 | pub const JVM_ACC_ANNOTATION_BIT: u32 = 13; 25 | pub const JVM_ACC_ENUM_BIT: u32 = 14; 26 | pub const JVM_ACC_PUBLIC: ::std::os::raw::c_uint = 1; 27 | pub const JVM_ACC_PRIVATE: ::std::os::raw::c_uint = 2; 28 | pub const JVM_ACC_PROTECTED: ::std::os::raw::c_uint = 4; 29 | pub const JVM_ACC_STATIC: ::std::os::raw::c_uint = 8; 30 | pub const JVM_ACC_FINAL: ::std::os::raw::c_uint = 16; 31 | pub const JVM_ACC_SYNCHRONIZED: ::std::os::raw::c_uint = 32; 32 | pub const JVM_ACC_SUPER: ::std::os::raw::c_uint = 32; 33 | pub const JVM_ACC_VOLATILE: ::std::os::raw::c_uint = 64; 34 | pub const JVM_ACC_BRIDGE: ::std::os::raw::c_uint = 64; 35 | pub const JVM_ACC_TRANSIENT: ::std::os::raw::c_uint = 128; 36 | pub const JVM_ACC_VARARGS: ::std::os::raw::c_uint = 128; 37 | pub const JVM_ACC_NATIVE: ::std::os::raw::c_uint = 256; 38 | pub const JVM_ACC_INTERFACE: ::std::os::raw::c_uint = 512; 39 | pub const JVM_ACC_ABSTRACT: ::std::os::raw::c_uint = 1024; 40 | pub const JVM_ACC_STRICT: ::std::os::raw::c_uint = 2048; 41 | pub const JVM_ACC_SYNTHETIC: ::std::os::raw::c_uint = 4096; 42 | pub const JVM_ACC_ANNOTATION: ::std::os::raw::c_uint = 8192; 43 | pub const JVM_ACC_ENUM: ::std::os::raw::c_uint = 16384; 44 | pub const JVM_ACC_MODULE: ::std::os::raw::c_uint = 32768; 45 | pub const JVM_T_BOOLEAN: ::std::os::raw::c_uint = 4; 46 | pub const JVM_T_CHAR: ::std::os::raw::c_uint = 5; 47 | pub const JVM_T_FLOAT: ::std::os::raw::c_uint = 6; 48 | pub const JVM_T_DOUBLE: ::std::os::raw::c_uint = 7; 49 | pub const JVM_T_BYTE: ::std::os::raw::c_uint = 8; 50 | pub const JVM_T_SHORT: ::std::os::raw::c_uint = 9; 51 | pub const JVM_T_INT: ::std::os::raw::c_uint = 10; 52 | pub const JVM_T_LONG: ::std::os::raw::c_uint = 11; 53 | pub const JVM_CONSTANT_Utf8: ::std::os::raw::c_uint = 1; 54 | pub const JVM_CONSTANT_Unicode: ::std::os::raw::c_uint = 2; 55 | pub const JVM_CONSTANT_Integer: ::std::os::raw::c_uint = 3; 56 | pub const JVM_CONSTANT_Float: ::std::os::raw::c_uint = 4; 57 | pub const JVM_CONSTANT_Long: ::std::os::raw::c_uint = 5; 58 | pub const JVM_CONSTANT_Double: ::std::os::raw::c_uint = 6; 59 | pub const JVM_CONSTANT_Class: ::std::os::raw::c_uint = 7; 60 | pub const JVM_CONSTANT_String: ::std::os::raw::c_uint = 8; 61 | pub const JVM_CONSTANT_Fieldref: ::std::os::raw::c_uint = 9; 62 | pub const JVM_CONSTANT_Methodref: ::std::os::raw::c_uint = 10; 63 | pub const JVM_CONSTANT_InterfaceMethodref: ::std::os::raw::c_uint = 11; 64 | pub const JVM_CONSTANT_NameAndType: ::std::os::raw::c_uint = 12; 65 | pub const JVM_CONSTANT_MethodHandle: ::std::os::raw::c_uint = 15; 66 | pub const JVM_CONSTANT_MethodType: ::std::os::raw::c_uint = 16; 67 | pub const JVM_CONSTANT_Dynamic: ::std::os::raw::c_uint = 17; 68 | pub const JVM_CONSTANT_InvokeDynamic: ::std::os::raw::c_uint = 18; 69 | pub const JVM_CONSTANT_Module: ::std::os::raw::c_uint = 19; 70 | pub const JVM_CONSTANT_Package: ::std::os::raw::c_uint = 20; 71 | pub const JVM_CONSTANT_ExternalMax: ::std::os::raw::c_uint = 20; 72 | pub const JVM_REF_getField: ::std::os::raw::c_uint = 1; 73 | pub const JVM_REF_getStatic: ::std::os::raw::c_uint = 2; 74 | pub const JVM_REF_putField: ::std::os::raw::c_uint = 3; 75 | pub const JVM_REF_putStatic: ::std::os::raw::c_uint = 4; 76 | pub const JVM_REF_invokeVirtual: ::std::os::raw::c_uint = 5; 77 | pub const JVM_REF_invokeStatic: ::std::os::raw::c_uint = 6; 78 | pub const JVM_REF_invokeSpecial: ::std::os::raw::c_uint = 7; 79 | pub const JVM_REF_newInvokeSpecial: ::std::os::raw::c_uint = 8; 80 | pub const JVM_REF_invokeInterface: ::std::os::raw::c_uint = 9; 81 | pub const JVM_ITEM_Top: ::std::os::raw::c_uint = 0; 82 | pub const JVM_ITEM_Integer: ::std::os::raw::c_uint = 1; 83 | pub const JVM_ITEM_Float: ::std::os::raw::c_uint = 2; 84 | pub const JVM_ITEM_Double: ::std::os::raw::c_uint = 3; 85 | pub const JVM_ITEM_Long: ::std::os::raw::c_uint = 4; 86 | pub const JVM_ITEM_Null: ::std::os::raw::c_uint = 5; 87 | pub const JVM_ITEM_UninitializedThis: ::std::os::raw::c_uint = 6; 88 | pub const JVM_ITEM_Object: ::std::os::raw::c_uint = 7; 89 | pub const JVM_ITEM_Uninitialized: ::std::os::raw::c_uint = 8; 90 | pub const JVM_SIGNATURE_SLASH: ::std::os::raw::c_uint = 47; 91 | pub const JVM_SIGNATURE_DOT: ::std::os::raw::c_uint = 46; 92 | pub const JVM_SIGNATURE_SPECIAL: ::std::os::raw::c_uint = 60; 93 | pub const JVM_SIGNATURE_ENDSPECIAL: ::std::os::raw::c_uint = 62; 94 | pub const JVM_SIGNATURE_ARRAY: ::std::os::raw::c_uint = 91; 95 | pub const JVM_SIGNATURE_BYTE: ::std::os::raw::c_uint = 66; 96 | pub const JVM_SIGNATURE_CHAR: ::std::os::raw::c_uint = 67; 97 | pub const JVM_SIGNATURE_CLASS: ::std::os::raw::c_uint = 76; 98 | pub const JVM_SIGNATURE_ENDCLASS: ::std::os::raw::c_uint = 59; 99 | pub const JVM_SIGNATURE_ENUM: ::std::os::raw::c_uint = 69; 100 | pub const JVM_SIGNATURE_FLOAT: ::std::os::raw::c_uint = 70; 101 | pub const JVM_SIGNATURE_DOUBLE: ::std::os::raw::c_uint = 68; 102 | pub const JVM_SIGNATURE_FUNC: ::std::os::raw::c_uint = 40; 103 | pub const JVM_SIGNATURE_ENDFUNC: ::std::os::raw::c_uint = 41; 104 | pub const JVM_SIGNATURE_INT: ::std::os::raw::c_uint = 73; 105 | pub const JVM_SIGNATURE_LONG: ::std::os::raw::c_uint = 74; 106 | pub const JVM_SIGNATURE_SHORT: ::std::os::raw::c_uint = 83; 107 | pub const JVM_SIGNATURE_VOID: ::std::os::raw::c_uint = 86; 108 | pub const JVM_SIGNATURE_BOOLEAN: ::std::os::raw::c_uint = 90; 109 | pub const JVM_OPC_nop: ::std::os::raw::c_uint = 0; 110 | pub const JVM_OPC_aconst_null: ::std::os::raw::c_uint = 1; 111 | pub const JVM_OPC_iconst_m1: ::std::os::raw::c_uint = 2; 112 | pub const JVM_OPC_iconst_0: ::std::os::raw::c_uint = 3; 113 | pub const JVM_OPC_iconst_1: ::std::os::raw::c_uint = 4; 114 | pub const JVM_OPC_iconst_2: ::std::os::raw::c_uint = 5; 115 | pub const JVM_OPC_iconst_3: ::std::os::raw::c_uint = 6; 116 | pub const JVM_OPC_iconst_4: ::std::os::raw::c_uint = 7; 117 | pub const JVM_OPC_iconst_5: ::std::os::raw::c_uint = 8; 118 | pub const JVM_OPC_lconst_0: ::std::os::raw::c_uint = 9; 119 | pub const JVM_OPC_lconst_1: ::std::os::raw::c_uint = 10; 120 | pub const JVM_OPC_fconst_0: ::std::os::raw::c_uint = 11; 121 | pub const JVM_OPC_fconst_1: ::std::os::raw::c_uint = 12; 122 | pub const JVM_OPC_fconst_2: ::std::os::raw::c_uint = 13; 123 | pub const JVM_OPC_dconst_0: ::std::os::raw::c_uint = 14; 124 | pub const JVM_OPC_dconst_1: ::std::os::raw::c_uint = 15; 125 | pub const JVM_OPC_bipush: ::std::os::raw::c_uint = 16; 126 | pub const JVM_OPC_sipush: ::std::os::raw::c_uint = 17; 127 | pub const JVM_OPC_ldc: ::std::os::raw::c_uint = 18; 128 | pub const JVM_OPC_ldc_w: ::std::os::raw::c_uint = 19; 129 | pub const JVM_OPC_ldc2_w: ::std::os::raw::c_uint = 20; 130 | pub const JVM_OPC_iload: ::std::os::raw::c_uint = 21; 131 | pub const JVM_OPC_lload: ::std::os::raw::c_uint = 22; 132 | pub const JVM_OPC_fload: ::std::os::raw::c_uint = 23; 133 | pub const JVM_OPC_dload: ::std::os::raw::c_uint = 24; 134 | pub const JVM_OPC_aload: ::std::os::raw::c_uint = 25; 135 | pub const JVM_OPC_iload_0: ::std::os::raw::c_uint = 26; 136 | pub const JVM_OPC_iload_1: ::std::os::raw::c_uint = 27; 137 | pub const JVM_OPC_iload_2: ::std::os::raw::c_uint = 28; 138 | pub const JVM_OPC_iload_3: ::std::os::raw::c_uint = 29; 139 | pub const JVM_OPC_lload_0: ::std::os::raw::c_uint = 30; 140 | pub const JVM_OPC_lload_1: ::std::os::raw::c_uint = 31; 141 | pub const JVM_OPC_lload_2: ::std::os::raw::c_uint = 32; 142 | pub const JVM_OPC_lload_3: ::std::os::raw::c_uint = 33; 143 | pub const JVM_OPC_fload_0: ::std::os::raw::c_uint = 34; 144 | pub const JVM_OPC_fload_1: ::std::os::raw::c_uint = 35; 145 | pub const JVM_OPC_fload_2: ::std::os::raw::c_uint = 36; 146 | pub const JVM_OPC_fload_3: ::std::os::raw::c_uint = 37; 147 | pub const JVM_OPC_dload_0: ::std::os::raw::c_uint = 38; 148 | pub const JVM_OPC_dload_1: ::std::os::raw::c_uint = 39; 149 | pub const JVM_OPC_dload_2: ::std::os::raw::c_uint = 40; 150 | pub const JVM_OPC_dload_3: ::std::os::raw::c_uint = 41; 151 | pub const JVM_OPC_aload_0: ::std::os::raw::c_uint = 42; 152 | pub const JVM_OPC_aload_1: ::std::os::raw::c_uint = 43; 153 | pub const JVM_OPC_aload_2: ::std::os::raw::c_uint = 44; 154 | pub const JVM_OPC_aload_3: ::std::os::raw::c_uint = 45; 155 | pub const JVM_OPC_iaload: ::std::os::raw::c_uint = 46; 156 | pub const JVM_OPC_laload: ::std::os::raw::c_uint = 47; 157 | pub const JVM_OPC_faload: ::std::os::raw::c_uint = 48; 158 | pub const JVM_OPC_daload: ::std::os::raw::c_uint = 49; 159 | pub const JVM_OPC_aaload: ::std::os::raw::c_uint = 50; 160 | pub const JVM_OPC_baload: ::std::os::raw::c_uint = 51; 161 | pub const JVM_OPC_caload: ::std::os::raw::c_uint = 52; 162 | pub const JVM_OPC_saload: ::std::os::raw::c_uint = 53; 163 | pub const JVM_OPC_istore: ::std::os::raw::c_uint = 54; 164 | pub const JVM_OPC_lstore: ::std::os::raw::c_uint = 55; 165 | pub const JVM_OPC_fstore: ::std::os::raw::c_uint = 56; 166 | pub const JVM_OPC_dstore: ::std::os::raw::c_uint = 57; 167 | pub const JVM_OPC_astore: ::std::os::raw::c_uint = 58; 168 | pub const JVM_OPC_istore_0: ::std::os::raw::c_uint = 59; 169 | pub const JVM_OPC_istore_1: ::std::os::raw::c_uint = 60; 170 | pub const JVM_OPC_istore_2: ::std::os::raw::c_uint = 61; 171 | pub const JVM_OPC_istore_3: ::std::os::raw::c_uint = 62; 172 | pub const JVM_OPC_lstore_0: ::std::os::raw::c_uint = 63; 173 | pub const JVM_OPC_lstore_1: ::std::os::raw::c_uint = 64; 174 | pub const JVM_OPC_lstore_2: ::std::os::raw::c_uint = 65; 175 | pub const JVM_OPC_lstore_3: ::std::os::raw::c_uint = 66; 176 | pub const JVM_OPC_fstore_0: ::std::os::raw::c_uint = 67; 177 | pub const JVM_OPC_fstore_1: ::std::os::raw::c_uint = 68; 178 | pub const JVM_OPC_fstore_2: ::std::os::raw::c_uint = 69; 179 | pub const JVM_OPC_fstore_3: ::std::os::raw::c_uint = 70; 180 | pub const JVM_OPC_dstore_0: ::std::os::raw::c_uint = 71; 181 | pub const JVM_OPC_dstore_1: ::std::os::raw::c_uint = 72; 182 | pub const JVM_OPC_dstore_2: ::std::os::raw::c_uint = 73; 183 | pub const JVM_OPC_dstore_3: ::std::os::raw::c_uint = 74; 184 | pub const JVM_OPC_astore_0: ::std::os::raw::c_uint = 75; 185 | pub const JVM_OPC_astore_1: ::std::os::raw::c_uint = 76; 186 | pub const JVM_OPC_astore_2: ::std::os::raw::c_uint = 77; 187 | pub const JVM_OPC_astore_3: ::std::os::raw::c_uint = 78; 188 | pub const JVM_OPC_iastore: ::std::os::raw::c_uint = 79; 189 | pub const JVM_OPC_lastore: ::std::os::raw::c_uint = 80; 190 | pub const JVM_OPC_fastore: ::std::os::raw::c_uint = 81; 191 | pub const JVM_OPC_dastore: ::std::os::raw::c_uint = 82; 192 | pub const JVM_OPC_aastore: ::std::os::raw::c_uint = 83; 193 | pub const JVM_OPC_bastore: ::std::os::raw::c_uint = 84; 194 | pub const JVM_OPC_castore: ::std::os::raw::c_uint = 85; 195 | pub const JVM_OPC_sastore: ::std::os::raw::c_uint = 86; 196 | pub const JVM_OPC_pop: ::std::os::raw::c_uint = 87; 197 | pub const JVM_OPC_pop2: ::std::os::raw::c_uint = 88; 198 | pub const JVM_OPC_dup: ::std::os::raw::c_uint = 89; 199 | pub const JVM_OPC_dup_x1: ::std::os::raw::c_uint = 90; 200 | pub const JVM_OPC_dup_x2: ::std::os::raw::c_uint = 91; 201 | pub const JVM_OPC_dup2: ::std::os::raw::c_uint = 92; 202 | pub const JVM_OPC_dup2_x1: ::std::os::raw::c_uint = 93; 203 | pub const JVM_OPC_dup2_x2: ::std::os::raw::c_uint = 94; 204 | pub const JVM_OPC_swap: ::std::os::raw::c_uint = 95; 205 | pub const JVM_OPC_iadd: ::std::os::raw::c_uint = 96; 206 | pub const JVM_OPC_ladd: ::std::os::raw::c_uint = 97; 207 | pub const JVM_OPC_fadd: ::std::os::raw::c_uint = 98; 208 | pub const JVM_OPC_dadd: ::std::os::raw::c_uint = 99; 209 | pub const JVM_OPC_isub: ::std::os::raw::c_uint = 100; 210 | pub const JVM_OPC_lsub: ::std::os::raw::c_uint = 101; 211 | pub const JVM_OPC_fsub: ::std::os::raw::c_uint = 102; 212 | pub const JVM_OPC_dsub: ::std::os::raw::c_uint = 103; 213 | pub const JVM_OPC_imul: ::std::os::raw::c_uint = 104; 214 | pub const JVM_OPC_lmul: ::std::os::raw::c_uint = 105; 215 | pub const JVM_OPC_fmul: ::std::os::raw::c_uint = 106; 216 | pub const JVM_OPC_dmul: ::std::os::raw::c_uint = 107; 217 | pub const JVM_OPC_idiv: ::std::os::raw::c_uint = 108; 218 | pub const JVM_OPC_ldiv: ::std::os::raw::c_uint = 109; 219 | pub const JVM_OPC_fdiv: ::std::os::raw::c_uint = 110; 220 | pub const JVM_OPC_ddiv: ::std::os::raw::c_uint = 111; 221 | pub const JVM_OPC_irem: ::std::os::raw::c_uint = 112; 222 | pub const JVM_OPC_lrem: ::std::os::raw::c_uint = 113; 223 | pub const JVM_OPC_frem: ::std::os::raw::c_uint = 114; 224 | pub const JVM_OPC_drem: ::std::os::raw::c_uint = 115; 225 | pub const JVM_OPC_ineg: ::std::os::raw::c_uint = 116; 226 | pub const JVM_OPC_lneg: ::std::os::raw::c_uint = 117; 227 | pub const JVM_OPC_fneg: ::std::os::raw::c_uint = 118; 228 | pub const JVM_OPC_dneg: ::std::os::raw::c_uint = 119; 229 | pub const JVM_OPC_ishl: ::std::os::raw::c_uint = 120; 230 | pub const JVM_OPC_lshl: ::std::os::raw::c_uint = 121; 231 | pub const JVM_OPC_ishr: ::std::os::raw::c_uint = 122; 232 | pub const JVM_OPC_lshr: ::std::os::raw::c_uint = 123; 233 | pub const JVM_OPC_iushr: ::std::os::raw::c_uint = 124; 234 | pub const JVM_OPC_lushr: ::std::os::raw::c_uint = 125; 235 | pub const JVM_OPC_iand: ::std::os::raw::c_uint = 126; 236 | pub const JVM_OPC_land: ::std::os::raw::c_uint = 127; 237 | pub const JVM_OPC_ior: ::std::os::raw::c_uint = 128; 238 | pub const JVM_OPC_lor: ::std::os::raw::c_uint = 129; 239 | pub const JVM_OPC_ixor: ::std::os::raw::c_uint = 130; 240 | pub const JVM_OPC_lxor: ::std::os::raw::c_uint = 131; 241 | pub const JVM_OPC_iinc: ::std::os::raw::c_uint = 132; 242 | pub const JVM_OPC_i2l: ::std::os::raw::c_uint = 133; 243 | pub const JVM_OPC_i2f: ::std::os::raw::c_uint = 134; 244 | pub const JVM_OPC_i2d: ::std::os::raw::c_uint = 135; 245 | pub const JVM_OPC_l2i: ::std::os::raw::c_uint = 136; 246 | pub const JVM_OPC_l2f: ::std::os::raw::c_uint = 137; 247 | pub const JVM_OPC_l2d: ::std::os::raw::c_uint = 138; 248 | pub const JVM_OPC_f2i: ::std::os::raw::c_uint = 139; 249 | pub const JVM_OPC_f2l: ::std::os::raw::c_uint = 140; 250 | pub const JVM_OPC_f2d: ::std::os::raw::c_uint = 141; 251 | pub const JVM_OPC_d2i: ::std::os::raw::c_uint = 142; 252 | pub const JVM_OPC_d2l: ::std::os::raw::c_uint = 143; 253 | pub const JVM_OPC_d2f: ::std::os::raw::c_uint = 144; 254 | pub const JVM_OPC_i2b: ::std::os::raw::c_uint = 145; 255 | pub const JVM_OPC_i2c: ::std::os::raw::c_uint = 146; 256 | pub const JVM_OPC_i2s: ::std::os::raw::c_uint = 147; 257 | pub const JVM_OPC_lcmp: ::std::os::raw::c_uint = 148; 258 | pub const JVM_OPC_fcmpl: ::std::os::raw::c_uint = 149; 259 | pub const JVM_OPC_fcmpg: ::std::os::raw::c_uint = 150; 260 | pub const JVM_OPC_dcmpl: ::std::os::raw::c_uint = 151; 261 | pub const JVM_OPC_dcmpg: ::std::os::raw::c_uint = 152; 262 | pub const JVM_OPC_ifeq: ::std::os::raw::c_uint = 153; 263 | pub const JVM_OPC_ifne: ::std::os::raw::c_uint = 154; 264 | pub const JVM_OPC_iflt: ::std::os::raw::c_uint = 155; 265 | pub const JVM_OPC_ifge: ::std::os::raw::c_uint = 156; 266 | pub const JVM_OPC_ifgt: ::std::os::raw::c_uint = 157; 267 | pub const JVM_OPC_ifle: ::std::os::raw::c_uint = 158; 268 | pub const JVM_OPC_if_icmpeq: ::std::os::raw::c_uint = 159; 269 | pub const JVM_OPC_if_icmpne: ::std::os::raw::c_uint = 160; 270 | pub const JVM_OPC_if_icmplt: ::std::os::raw::c_uint = 161; 271 | pub const JVM_OPC_if_icmpge: ::std::os::raw::c_uint = 162; 272 | pub const JVM_OPC_if_icmpgt: ::std::os::raw::c_uint = 163; 273 | pub const JVM_OPC_if_icmple: ::std::os::raw::c_uint = 164; 274 | pub const JVM_OPC_if_acmpeq: ::std::os::raw::c_uint = 165; 275 | pub const JVM_OPC_if_acmpne: ::std::os::raw::c_uint = 166; 276 | pub const JVM_OPC_goto: ::std::os::raw::c_uint = 167; 277 | pub const JVM_OPC_jsr: ::std::os::raw::c_uint = 168; 278 | pub const JVM_OPC_ret: ::std::os::raw::c_uint = 169; 279 | pub const JVM_OPC_tableswitch: ::std::os::raw::c_uint = 170; 280 | pub const JVM_OPC_lookupswitch: ::std::os::raw::c_uint = 171; 281 | pub const JVM_OPC_ireturn: ::std::os::raw::c_uint = 172; 282 | pub const JVM_OPC_lreturn: ::std::os::raw::c_uint = 173; 283 | pub const JVM_OPC_freturn: ::std::os::raw::c_uint = 174; 284 | pub const JVM_OPC_dreturn: ::std::os::raw::c_uint = 175; 285 | pub const JVM_OPC_areturn: ::std::os::raw::c_uint = 176; 286 | pub const JVM_OPC_return: ::std::os::raw::c_uint = 177; 287 | pub const JVM_OPC_getstatic: ::std::os::raw::c_uint = 178; 288 | pub const JVM_OPC_putstatic: ::std::os::raw::c_uint = 179; 289 | pub const JVM_OPC_getfield: ::std::os::raw::c_uint = 180; 290 | pub const JVM_OPC_putfield: ::std::os::raw::c_uint = 181; 291 | pub const JVM_OPC_invokevirtual: ::std::os::raw::c_uint = 182; 292 | pub const JVM_OPC_invokespecial: ::std::os::raw::c_uint = 183; 293 | pub const JVM_OPC_invokestatic: ::std::os::raw::c_uint = 184; 294 | pub const JVM_OPC_invokeinterface: ::std::os::raw::c_uint = 185; 295 | pub const JVM_OPC_invokedynamic: ::std::os::raw::c_uint = 186; 296 | pub const JVM_OPC_new: ::std::os::raw::c_uint = 187; 297 | pub const JVM_OPC_newarray: ::std::os::raw::c_uint = 188; 298 | pub const JVM_OPC_anewarray: ::std::os::raw::c_uint = 189; 299 | pub const JVM_OPC_arraylength: ::std::os::raw::c_uint = 190; 300 | pub const JVM_OPC_athrow: ::std::os::raw::c_uint = 191; 301 | pub const JVM_OPC_checkcast: ::std::os::raw::c_uint = 192; 302 | pub const JVM_OPC_instanceof: ::std::os::raw::c_uint = 193; 303 | pub const JVM_OPC_monitorenter: ::std::os::raw::c_uint = 194; 304 | pub const JVM_OPC_monitorexit: ::std::os::raw::c_uint = 195; 305 | pub const JVM_OPC_wide: ::std::os::raw::c_uint = 196; 306 | pub const JVM_OPC_multianewarray: ::std::os::raw::c_uint = 197; 307 | pub const JVM_OPC_ifnull: ::std::os::raw::c_uint = 198; 308 | pub const JVM_OPC_ifnonnull: ::std::os::raw::c_uint = 199; 309 | pub const JVM_OPC_goto_w: ::std::os::raw::c_uint = 200; 310 | pub const JVM_OPC_jsr_w: ::std::os::raw::c_uint = 201; 311 | pub const JVM_OPC_MAX: ::std::os::raw::c_uint = 201; 312 | -------------------------------------------------------------------------------- /src/jawt.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(dead_code)] 5 | 6 | use crate::jni::*; 7 | 8 | pub const JAWT_LOCK_ERROR: u32 = 1; 9 | pub const JAWT_LOCK_CLIP_CHANGED: u32 = 2; 10 | pub const JAWT_LOCK_BOUNDS_CHANGED: u32 = 4; 11 | pub const JAWT_LOCK_SURFACE_CHANGED: u32 = 8; 12 | pub const JAWT_VERSION_1_3: u32 = 65539; 13 | pub const JAWT_VERSION_1_4: u32 = 65540; 14 | pub const JAWT_VERSION_1_7: u32 = 65543; 15 | pub const JAWT_VERSION_9: u32 = 589824; 16 | #[repr(C)] 17 | #[derive(Debug, Copy, Clone)] 18 | pub struct jawt_Rectangle { 19 | pub x: jint, 20 | pub y: jint, 21 | pub width: jint, 22 | pub height: jint, 23 | } 24 | pub type JAWT_Rectangle = jawt_Rectangle; 25 | #[repr(C)] 26 | #[derive(Debug, Copy, Clone)] 27 | pub struct jawt_DrawingSurfaceInfo { 28 | pub platformInfo: *mut ::std::os::raw::c_void, 29 | pub ds: *mut jawt_DrawingSurface, 30 | pub bounds: JAWT_Rectangle, 31 | pub clipSize: jint, 32 | pub clip: *mut JAWT_Rectangle, 33 | } 34 | pub type JAWT_DrawingSurfaceInfo = jawt_DrawingSurfaceInfo; 35 | #[repr(C)] 36 | #[derive(Debug, Copy, Clone)] 37 | pub struct jawt_DrawingSurface { 38 | pub env: *mut JNIEnv, 39 | pub target: jobject, 40 | pub Lock: ::std::option::Option jint>, 41 | pub GetDrawingSurfaceInfo: ::std::option::Option< 42 | unsafe extern "C" fn(ds: *mut jawt_DrawingSurface) -> *mut JAWT_DrawingSurfaceInfo, 43 | >, 44 | pub FreeDrawingSurfaceInfo: 45 | ::std::option::Option, 46 | pub Unlock: ::std::option::Option, 47 | } 48 | pub type JAWT_DrawingSurface = jawt_DrawingSurface; 49 | #[repr(C)] 50 | #[derive(Debug, Copy, Clone)] 51 | pub struct jawt { 52 | pub version: jint, 53 | pub GetDrawingSurface: ::std::option::Option< 54 | unsafe extern "C" fn(env: *mut JNIEnv, target: jobject) -> *mut JAWT_DrawingSurface, 55 | >, 56 | pub FreeDrawingSurface: 57 | ::std::option::Option, 58 | pub Lock: ::std::option::Option, 59 | pub Unlock: ::std::option::Option, 60 | pub GetComponent: ::std::option::Option< 61 | unsafe extern "C" fn( 62 | env: *mut JNIEnv, 63 | platformInfo: *mut ::std::os::raw::c_void, 64 | ) -> jobject, 65 | >, 66 | #[doc = " Since 9"] 67 | #[doc = " Creates a java.awt.Frame placed in a native container. Container is"] 68 | #[doc = " referenced by the native platform handle. For example on Windows this"] 69 | #[doc = " corresponds to an HWND. For other platforms, see the appropriate"] 70 | #[doc = " machine-dependent header file for a description. The reference returned"] 71 | #[doc = " by this function is a local reference that is only valid in this"] 72 | #[doc = " environment. This function returns a NULL reference if no frame could be"] 73 | #[doc = " created with matching platform information."] 74 | pub CreateEmbeddedFrame: ::std::option::Option< 75 | unsafe extern "C" fn( 76 | env: *mut JNIEnv, 77 | platformInfo: *mut ::std::os::raw::c_void, 78 | ) -> jobject, 79 | >, 80 | #[doc = " Since 9"] 81 | #[doc = " Moves and resizes the embedded frame. The new location of the top-left"] 82 | #[doc = " corner is specified by x and y parameters relative to the native parent"] 83 | #[doc = " component. The new size is specified by width and height."] 84 | #[doc = ""] 85 | #[doc = " The embedded frame should be created by CreateEmbeddedFrame() method, or"] 86 | #[doc = " this function will not have any effect."] 87 | #[doc = ""] 88 | #[doc = " java.awt.Component.setLocation() and java.awt.Component.setBounds() for"] 89 | #[doc = " EmbeddedFrame really don't move it within the native parent. These"] 90 | #[doc = " methods always locate the embedded frame at (0, 0) for backward"] 91 | #[doc = " compatibility. To allow moving embedded frames this method was"] 92 | #[doc = " introduced, and it works just the same way as setLocation() and"] 93 | #[doc = " setBounds() for usual, non-embedded components."] 94 | #[doc = ""] 95 | #[doc = " Using usual get/setLocation() and get/setBounds() together with this new"] 96 | #[doc = " method is not recommended."] 97 | pub SetBounds: ::std::option::Option< 98 | unsafe extern "C" fn( 99 | env: *mut JNIEnv, 100 | embeddedFrame: jobject, 101 | x: jint, 102 | y: jint, 103 | w: jint, 104 | h: jint, 105 | ), 106 | >, 107 | #[doc = " Since 9"] 108 | #[doc = " Synthesize a native message to activate or deactivate an EmbeddedFrame"] 109 | #[doc = " window depending on the value of parameter doActivate, if \"true\""] 110 | #[doc = " activates the window; otherwise, deactivates the window."] 111 | #[doc = ""] 112 | #[doc = " The embedded frame should be created by CreateEmbeddedFrame() method, or"] 113 | #[doc = " this function will not have any effect."] 114 | pub SynthesizeWindowActivation: ::std::option::Option< 115 | unsafe extern "C" fn(env: *mut JNIEnv, embeddedFrame: jobject, doActivate: jboolean), 116 | >, 117 | } 118 | pub type JAWT = jawt; 119 | extern "C" { 120 | pub fn JAWT_GetAWT(env: *mut JNIEnv, awt: *mut JAWT) -> jboolean; 121 | } 122 | -------------------------------------------------------------------------------- /src/jdwpTransport.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(dead_code)] 5 | 6 | use crate::bitfield::__BindgenBitfieldUnit; 7 | use crate::jni::*; 8 | 9 | pub const JDWPTRANSPORT_VERSION_1_0: ::std::os::raw::c_uint = 65536; 10 | pub const JDWPTRANSPORT_VERSION_1_1: ::std::os::raw::c_uint = 65537; 11 | pub type jdwpTransportEnv = *const jdwpTransportNativeInterface_; 12 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_NONE: jdwpTransportError = 0; 13 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT: jdwpTransportError = 103; 14 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_OUT_OF_MEMORY: jdwpTransportError = 110; 15 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_INTERNAL: jdwpTransportError = 113; 16 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_ILLEGAL_STATE: jdwpTransportError = 201; 17 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_IO_ERROR: jdwpTransportError = 202; 18 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_TIMEOUT: jdwpTransportError = 203; 19 | pub const jdwpTransportError_JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE: jdwpTransportError = 204; 20 | pub type jdwpTransportError = ::std::os::raw::c_uint; 21 | #[repr(C)] 22 | #[repr(align(4))] 23 | #[derive(Debug, Copy, Clone)] 24 | pub struct JDWPTransportCapabilities { 25 | pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, 26 | pub __bindgen_padding_0: u16, 27 | } 28 | impl JDWPTransportCapabilities { 29 | #[inline] 30 | pub fn can_timeout_attach(&self) -> ::std::os::raw::c_uint { 31 | unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } 32 | } 33 | #[inline] 34 | pub fn set_can_timeout_attach(&mut self, val: ::std::os::raw::c_uint) { 35 | unsafe { 36 | let val: u32 = ::std::mem::transmute(val); 37 | self._bitfield_1.set(0usize, 1u8, val as u64) 38 | } 39 | } 40 | #[inline] 41 | pub fn can_timeout_accept(&self) -> ::std::os::raw::c_uint { 42 | unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) } 43 | } 44 | #[inline] 45 | pub fn set_can_timeout_accept(&mut self, val: ::std::os::raw::c_uint) { 46 | unsafe { 47 | let val: u32 = ::std::mem::transmute(val); 48 | self._bitfield_1.set(1usize, 1u8, val as u64) 49 | } 50 | } 51 | #[inline] 52 | pub fn can_timeout_handshake(&self) -> ::std::os::raw::c_uint { 53 | unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } 54 | } 55 | #[inline] 56 | pub fn set_can_timeout_handshake(&mut self, val: ::std::os::raw::c_uint) { 57 | unsafe { 58 | let val: u32 = ::std::mem::transmute(val); 59 | self._bitfield_1.set(2usize, 1u8, val as u64) 60 | } 61 | } 62 | #[inline] 63 | pub fn reserved3(&self) -> ::std::os::raw::c_uint { 64 | unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } 65 | } 66 | #[inline] 67 | pub fn set_reserved3(&mut self, val: ::std::os::raw::c_uint) { 68 | unsafe { 69 | let val: u32 = ::std::mem::transmute(val); 70 | self._bitfield_1.set(3usize, 1u8, val as u64) 71 | } 72 | } 73 | #[inline] 74 | pub fn reserved4(&self) -> ::std::os::raw::c_uint { 75 | unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u32) } 76 | } 77 | #[inline] 78 | pub fn set_reserved4(&mut self, val: ::std::os::raw::c_uint) { 79 | unsafe { 80 | let val: u32 = ::std::mem::transmute(val); 81 | self._bitfield_1.set(4usize, 1u8, val as u64) 82 | } 83 | } 84 | #[inline] 85 | pub fn reserved5(&self) -> ::std::os::raw::c_uint { 86 | unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) } 87 | } 88 | #[inline] 89 | pub fn set_reserved5(&mut self, val: ::std::os::raw::c_uint) { 90 | unsafe { 91 | let val: u32 = ::std::mem::transmute(val); 92 | self._bitfield_1.set(5usize, 1u8, val as u64) 93 | } 94 | } 95 | #[inline] 96 | pub fn reserved6(&self) -> ::std::os::raw::c_uint { 97 | unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u32) } 98 | } 99 | #[inline] 100 | pub fn set_reserved6(&mut self, val: ::std::os::raw::c_uint) { 101 | unsafe { 102 | let val: u32 = ::std::mem::transmute(val); 103 | self._bitfield_1.set(6usize, 1u8, val as u64) 104 | } 105 | } 106 | #[inline] 107 | pub fn reserved7(&self) -> ::std::os::raw::c_uint { 108 | unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u32) } 109 | } 110 | #[inline] 111 | pub fn set_reserved7(&mut self, val: ::std::os::raw::c_uint) { 112 | unsafe { 113 | let val: u32 = ::std::mem::transmute(val); 114 | self._bitfield_1.set(7usize, 1u8, val as u64) 115 | } 116 | } 117 | #[inline] 118 | pub fn reserved8(&self) -> ::std::os::raw::c_uint { 119 | unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u32) } 120 | } 121 | #[inline] 122 | pub fn set_reserved8(&mut self, val: ::std::os::raw::c_uint) { 123 | unsafe { 124 | let val: u32 = ::std::mem::transmute(val); 125 | self._bitfield_1.set(8usize, 1u8, val as u64) 126 | } 127 | } 128 | #[inline] 129 | pub fn reserved9(&self) -> ::std::os::raw::c_uint { 130 | unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u32) } 131 | } 132 | #[inline] 133 | pub fn set_reserved9(&mut self, val: ::std::os::raw::c_uint) { 134 | unsafe { 135 | let val: u32 = ::std::mem::transmute(val); 136 | self._bitfield_1.set(9usize, 1u8, val as u64) 137 | } 138 | } 139 | #[inline] 140 | pub fn reserved10(&self) -> ::std::os::raw::c_uint { 141 | unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u32) } 142 | } 143 | #[inline] 144 | pub fn set_reserved10(&mut self, val: ::std::os::raw::c_uint) { 145 | unsafe { 146 | let val: u32 = ::std::mem::transmute(val); 147 | self._bitfield_1.set(10usize, 1u8, val as u64) 148 | } 149 | } 150 | #[inline] 151 | pub fn reserved11(&self) -> ::std::os::raw::c_uint { 152 | unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u32) } 153 | } 154 | #[inline] 155 | pub fn set_reserved11(&mut self, val: ::std::os::raw::c_uint) { 156 | unsafe { 157 | let val: u32 = ::std::mem::transmute(val); 158 | self._bitfield_1.set(11usize, 1u8, val as u64) 159 | } 160 | } 161 | #[inline] 162 | pub fn reserved12(&self) -> ::std::os::raw::c_uint { 163 | unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u32) } 164 | } 165 | #[inline] 166 | pub fn set_reserved12(&mut self, val: ::std::os::raw::c_uint) { 167 | unsafe { 168 | let val: u32 = ::std::mem::transmute(val); 169 | self._bitfield_1.set(12usize, 1u8, val as u64) 170 | } 171 | } 172 | #[inline] 173 | pub fn reserved13(&self) -> ::std::os::raw::c_uint { 174 | unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u32) } 175 | } 176 | #[inline] 177 | pub fn set_reserved13(&mut self, val: ::std::os::raw::c_uint) { 178 | unsafe { 179 | let val: u32 = ::std::mem::transmute(val); 180 | self._bitfield_1.set(13usize, 1u8, val as u64) 181 | } 182 | } 183 | #[inline] 184 | pub fn reserved14(&self) -> ::std::os::raw::c_uint { 185 | unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u32) } 186 | } 187 | #[inline] 188 | pub fn set_reserved14(&mut self, val: ::std::os::raw::c_uint) { 189 | unsafe { 190 | let val: u32 = ::std::mem::transmute(val); 191 | self._bitfield_1.set(14usize, 1u8, val as u64) 192 | } 193 | } 194 | #[inline] 195 | pub fn reserved15(&self) -> ::std::os::raw::c_uint { 196 | unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u32) } 197 | } 198 | #[inline] 199 | pub fn set_reserved15(&mut self, val: ::std::os::raw::c_uint) { 200 | unsafe { 201 | let val: u32 = ::std::mem::transmute(val); 202 | self._bitfield_1.set(15usize, 1u8, val as u64) 203 | } 204 | } 205 | #[inline] 206 | pub fn new_bitfield_1( 207 | can_timeout_attach: ::std::os::raw::c_uint, 208 | can_timeout_accept: ::std::os::raw::c_uint, 209 | can_timeout_handshake: ::std::os::raw::c_uint, 210 | reserved3: ::std::os::raw::c_uint, 211 | reserved4: ::std::os::raw::c_uint, 212 | reserved5: ::std::os::raw::c_uint, 213 | reserved6: ::std::os::raw::c_uint, 214 | reserved7: ::std::os::raw::c_uint, 215 | reserved8: ::std::os::raw::c_uint, 216 | reserved9: ::std::os::raw::c_uint, 217 | reserved10: ::std::os::raw::c_uint, 218 | reserved11: ::std::os::raw::c_uint, 219 | reserved12: ::std::os::raw::c_uint, 220 | reserved13: ::std::os::raw::c_uint, 221 | reserved14: ::std::os::raw::c_uint, 222 | reserved15: ::std::os::raw::c_uint, 223 | ) -> __BindgenBitfieldUnit<[u8; 2usize], u8> { 224 | let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize], u8> = 225 | Default::default(); 226 | __bindgen_bitfield_unit.set(0usize, 1u8, { 227 | let can_timeout_attach: u32 = unsafe { ::std::mem::transmute(can_timeout_attach) }; 228 | can_timeout_attach as u64 229 | }); 230 | __bindgen_bitfield_unit.set(1usize, 1u8, { 231 | let can_timeout_accept: u32 = unsafe { ::std::mem::transmute(can_timeout_accept) }; 232 | can_timeout_accept as u64 233 | }); 234 | __bindgen_bitfield_unit.set(2usize, 1u8, { 235 | let can_timeout_handshake: u32 = 236 | unsafe { ::std::mem::transmute(can_timeout_handshake) }; 237 | can_timeout_handshake as u64 238 | }); 239 | __bindgen_bitfield_unit.set(3usize, 1u8, { 240 | let reserved3: u32 = unsafe { ::std::mem::transmute(reserved3) }; 241 | reserved3 as u64 242 | }); 243 | __bindgen_bitfield_unit.set(4usize, 1u8, { 244 | let reserved4: u32 = unsafe { ::std::mem::transmute(reserved4) }; 245 | reserved4 as u64 246 | }); 247 | __bindgen_bitfield_unit.set(5usize, 1u8, { 248 | let reserved5: u32 = unsafe { ::std::mem::transmute(reserved5) }; 249 | reserved5 as u64 250 | }); 251 | __bindgen_bitfield_unit.set(6usize, 1u8, { 252 | let reserved6: u32 = unsafe { ::std::mem::transmute(reserved6) }; 253 | reserved6 as u64 254 | }); 255 | __bindgen_bitfield_unit.set(7usize, 1u8, { 256 | let reserved7: u32 = unsafe { ::std::mem::transmute(reserved7) }; 257 | reserved7 as u64 258 | }); 259 | __bindgen_bitfield_unit.set(8usize, 1u8, { 260 | let reserved8: u32 = unsafe { ::std::mem::transmute(reserved8) }; 261 | reserved8 as u64 262 | }); 263 | __bindgen_bitfield_unit.set(9usize, 1u8, { 264 | let reserved9: u32 = unsafe { ::std::mem::transmute(reserved9) }; 265 | reserved9 as u64 266 | }); 267 | __bindgen_bitfield_unit.set(10usize, 1u8, { 268 | let reserved10: u32 = unsafe { ::std::mem::transmute(reserved10) }; 269 | reserved10 as u64 270 | }); 271 | __bindgen_bitfield_unit.set(11usize, 1u8, { 272 | let reserved11: u32 = unsafe { ::std::mem::transmute(reserved11) }; 273 | reserved11 as u64 274 | }); 275 | __bindgen_bitfield_unit.set(12usize, 1u8, { 276 | let reserved12: u32 = unsafe { ::std::mem::transmute(reserved12) }; 277 | reserved12 as u64 278 | }); 279 | __bindgen_bitfield_unit.set(13usize, 1u8, { 280 | let reserved13: u32 = unsafe { ::std::mem::transmute(reserved13) }; 281 | reserved13 as u64 282 | }); 283 | __bindgen_bitfield_unit.set(14usize, 1u8, { 284 | let reserved14: u32 = unsafe { ::std::mem::transmute(reserved14) }; 285 | reserved14 as u64 286 | }); 287 | __bindgen_bitfield_unit.set(15usize, 1u8, { 288 | let reserved15: u32 = unsafe { ::std::mem::transmute(reserved15) }; 289 | reserved15 as u64 290 | }); 291 | __bindgen_bitfield_unit 292 | } 293 | } 294 | pub const JDWPTRANSPORT_FLAGS_NONE: ::std::os::raw::c_uint = 0; 295 | pub const JDWPTRANSPORT_FLAGS_REPLY: ::std::os::raw::c_uint = 128; 296 | #[repr(C)] 297 | #[derive(Debug, Copy, Clone)] 298 | pub struct jdwpCmdPacket { 299 | pub len: jint, 300 | pub id: jint, 301 | pub flags: jbyte, 302 | pub cmdSet: jbyte, 303 | pub cmd: jbyte, 304 | pub data: *mut jbyte, 305 | } 306 | #[repr(C)] 307 | #[derive(Debug, Copy, Clone)] 308 | pub struct jdwpReplyPacket { 309 | pub len: jint, 310 | pub id: jint, 311 | pub flags: jbyte, 312 | pub errorCode: jshort, 313 | pub data: *mut jbyte, 314 | } 315 | #[repr(C)] 316 | #[derive(Copy, Clone)] 317 | pub struct jdwpPacket { 318 | pub type_: jdwpPacket__bindgen_ty_1, 319 | } 320 | #[repr(C)] 321 | #[derive(Copy, Clone)] 322 | pub union jdwpPacket__bindgen_ty_1 { 323 | pub cmd: jdwpCmdPacket, 324 | pub reply: jdwpReplyPacket, 325 | _bindgen_union_align: [u64; 3usize], 326 | } 327 | #[repr(C)] 328 | #[derive(Debug, Copy, Clone)] 329 | pub struct jdwpTransportCallback { 330 | pub alloc: 331 | ::std::option::Option *mut ::std::os::raw::c_void>, 332 | pub free: ::std::option::Option, 333 | } 334 | pub type jdwpTransport_OnLoad_t = ::std::option::Option< 335 | unsafe extern "C" fn( 336 | jvm: *mut JavaVM, 337 | callback: *mut jdwpTransportCallback, 338 | version: jint, 339 | env: *mut *mut jdwpTransportEnv, 340 | ) -> jint, 341 | >; 342 | #[repr(C)] 343 | #[derive(Debug, Copy, Clone)] 344 | pub struct jdwpTransportConfiguration { 345 | pub allowed_peers: *const ::std::os::raw::c_char, 346 | } 347 | #[repr(C)] 348 | #[derive(Debug, Copy, Clone)] 349 | pub struct jdwpTransportNativeInterface_ { 350 | pub reserved1: *mut ::std::os::raw::c_void, 351 | pub GetCapabilities: ::std::option::Option< 352 | unsafe extern "C" fn( 353 | env: *mut jdwpTransportEnv, 354 | capabilities_ptr: *mut JDWPTransportCapabilities, 355 | ) -> jdwpTransportError, 356 | >, 357 | pub Attach: ::std::option::Option< 358 | unsafe extern "C" fn( 359 | env: *mut jdwpTransportEnv, 360 | address: *const ::std::os::raw::c_char, 361 | attach_timeout: jlong, 362 | handshake_timeout: jlong, 363 | ) -> jdwpTransportError, 364 | >, 365 | pub StartListening: ::std::option::Option< 366 | unsafe extern "C" fn( 367 | env: *mut jdwpTransportEnv, 368 | address: *const ::std::os::raw::c_char, 369 | actual_address: *mut *mut ::std::os::raw::c_char, 370 | ) -> jdwpTransportError, 371 | >, 372 | pub StopListening: ::std::option::Option< 373 | unsafe extern "C" fn(env: *mut jdwpTransportEnv) -> jdwpTransportError, 374 | >, 375 | pub Accept: ::std::option::Option< 376 | unsafe extern "C" fn( 377 | env: *mut jdwpTransportEnv, 378 | accept_timeout: jlong, 379 | handshake_timeout: jlong, 380 | ) -> jdwpTransportError, 381 | >, 382 | pub IsOpen: ::std::option::Option jboolean>, 383 | pub Close: ::std::option::Option< 384 | unsafe extern "C" fn(env: *mut jdwpTransportEnv) -> jdwpTransportError, 385 | >, 386 | pub ReadPacket: ::std::option::Option< 387 | unsafe extern "C" fn( 388 | env: *mut jdwpTransportEnv, 389 | pkt: *mut jdwpPacket, 390 | ) -> jdwpTransportError, 391 | >, 392 | pub WritePacket: ::std::option::Option< 393 | unsafe extern "C" fn( 394 | env: *mut jdwpTransportEnv, 395 | pkt: *const jdwpPacket, 396 | ) -> jdwpTransportError, 397 | >, 398 | pub GetLastError: ::std::option::Option< 399 | unsafe extern "C" fn( 400 | env: *mut jdwpTransportEnv, 401 | error: *mut *mut ::std::os::raw::c_char, 402 | ) -> jdwpTransportError, 403 | >, 404 | pub SetTransportConfiguration: ::std::option::Option< 405 | unsafe extern "C" fn( 406 | env: *mut jdwpTransportEnv, 407 | config: *mut jdwpTransportConfiguration, 408 | ) -> jdwpTransportError, 409 | >, 410 | } 411 | #[repr(C)] 412 | #[derive(Debug, Copy, Clone)] 413 | pub struct _jdwpTransportEnv { 414 | pub functions: *const jdwpTransportNativeInterface_, 415 | } 416 | -------------------------------------------------------------------------------- /src/jmm.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(dead_code)] 5 | 6 | use crate::bitfield::__BindgenBitfieldUnit; 7 | use crate::jni::*; 8 | 9 | pub const JMM_VERSION_1: ::std::os::raw::c_uint = 536936448; 10 | pub const JMM_VERSION_1_0: ::std::os::raw::c_uint = 536936448; 11 | pub const JMM_VERSION_1_1: ::std::os::raw::c_uint = 536936704; 12 | pub const JMM_VERSION_1_2: ::std::os::raw::c_uint = 536936960; 13 | pub const JMM_VERSION_1_2_1: ::std::os::raw::c_uint = 536936961; 14 | pub const JMM_VERSION_1_2_2: ::std::os::raw::c_uint = 536936962; 15 | pub const JMM_VERSION_2: ::std::os::raw::c_uint = 537001984; 16 | pub const JMM_VERSION_3: ::std::os::raw::c_uint = 537067520; 17 | pub const JMM_VERSION: ::std::os::raw::c_uint = 537067520; 18 | #[repr(C)] 19 | #[repr(align(4))] 20 | #[derive(Debug, Copy, Clone)] 21 | pub struct jmmOptionalSupport { 22 | pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>, 23 | } 24 | impl jmmOptionalSupport { 25 | #[inline] 26 | pub fn isLowMemoryDetectionSupported(&self) -> ::std::os::raw::c_uint { 27 | unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } 28 | } 29 | #[inline] 30 | pub fn set_isLowMemoryDetectionSupported(&mut self, val: ::std::os::raw::c_uint) { 31 | unsafe { 32 | let val: u32 = ::std::mem::transmute(val); 33 | self._bitfield_1.set(0usize, 1u8, val as u64) 34 | } 35 | } 36 | #[inline] 37 | pub fn isCompilationTimeMonitoringSupported(&self) -> ::std::os::raw::c_uint { 38 | unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) } 39 | } 40 | #[inline] 41 | pub fn set_isCompilationTimeMonitoringSupported(&mut self, val: ::std::os::raw::c_uint) { 42 | unsafe { 43 | let val: u32 = ::std::mem::transmute(val); 44 | self._bitfield_1.set(1usize, 1u8, val as u64) 45 | } 46 | } 47 | #[inline] 48 | pub fn isThreadContentionMonitoringSupported(&self) -> ::std::os::raw::c_uint { 49 | unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } 50 | } 51 | #[inline] 52 | pub fn set_isThreadContentionMonitoringSupported(&mut self, val: ::std::os::raw::c_uint) { 53 | unsafe { 54 | let val: u32 = ::std::mem::transmute(val); 55 | self._bitfield_1.set(2usize, 1u8, val as u64) 56 | } 57 | } 58 | #[inline] 59 | pub fn isCurrentThreadCpuTimeSupported(&self) -> ::std::os::raw::c_uint { 60 | unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } 61 | } 62 | #[inline] 63 | pub fn set_isCurrentThreadCpuTimeSupported(&mut self, val: ::std::os::raw::c_uint) { 64 | unsafe { 65 | let val: u32 = ::std::mem::transmute(val); 66 | self._bitfield_1.set(3usize, 1u8, val as u64) 67 | } 68 | } 69 | #[inline] 70 | pub fn isOtherThreadCpuTimeSupported(&self) -> ::std::os::raw::c_uint { 71 | unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u32) } 72 | } 73 | #[inline] 74 | pub fn set_isOtherThreadCpuTimeSupported(&mut self, val: ::std::os::raw::c_uint) { 75 | unsafe { 76 | let val: u32 = ::std::mem::transmute(val); 77 | self._bitfield_1.set(4usize, 1u8, val as u64) 78 | } 79 | } 80 | #[inline] 81 | pub fn isObjectMonitorUsageSupported(&self) -> ::std::os::raw::c_uint { 82 | unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) } 83 | } 84 | #[inline] 85 | pub fn set_isObjectMonitorUsageSupported(&mut self, val: ::std::os::raw::c_uint) { 86 | unsafe { 87 | let val: u32 = ::std::mem::transmute(val); 88 | self._bitfield_1.set(5usize, 1u8, val as u64) 89 | } 90 | } 91 | #[inline] 92 | pub fn isSynchronizerUsageSupported(&self) -> ::std::os::raw::c_uint { 93 | unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u32) } 94 | } 95 | #[inline] 96 | pub fn set_isSynchronizerUsageSupported(&mut self, val: ::std::os::raw::c_uint) { 97 | unsafe { 98 | let val: u32 = ::std::mem::transmute(val); 99 | self._bitfield_1.set(6usize, 1u8, val as u64) 100 | } 101 | } 102 | #[inline] 103 | pub fn isThreadAllocatedMemorySupported(&self) -> ::std::os::raw::c_uint { 104 | unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u32) } 105 | } 106 | #[inline] 107 | pub fn set_isThreadAllocatedMemorySupported(&mut self, val: ::std::os::raw::c_uint) { 108 | unsafe { 109 | let val: u32 = ::std::mem::transmute(val); 110 | self._bitfield_1.set(7usize, 1u8, val as u64) 111 | } 112 | } 113 | #[inline] 114 | pub fn isRemoteDiagnosticCommandsSupported(&self) -> ::std::os::raw::c_uint { 115 | unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u32) } 116 | } 117 | #[inline] 118 | pub fn set_isRemoteDiagnosticCommandsSupported(&mut self, val: ::std::os::raw::c_uint) { 119 | unsafe { 120 | let val: u32 = ::std::mem::transmute(val); 121 | self._bitfield_1.set(8usize, 1u8, val as u64) 122 | } 123 | } 124 | #[inline] 125 | pub fn new_bitfield_1( 126 | isLowMemoryDetectionSupported: ::std::os::raw::c_uint, 127 | isCompilationTimeMonitoringSupported: ::std::os::raw::c_uint, 128 | isThreadContentionMonitoringSupported: ::std::os::raw::c_uint, 129 | isCurrentThreadCpuTimeSupported: ::std::os::raw::c_uint, 130 | isOtherThreadCpuTimeSupported: ::std::os::raw::c_uint, 131 | isObjectMonitorUsageSupported: ::std::os::raw::c_uint, 132 | isSynchronizerUsageSupported: ::std::os::raw::c_uint, 133 | isThreadAllocatedMemorySupported: ::std::os::raw::c_uint, 134 | isRemoteDiagnosticCommandsSupported: ::std::os::raw::c_uint, 135 | ) -> __BindgenBitfieldUnit<[u8; 4usize], u8> { 136 | let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u8> = 137 | Default::default(); 138 | __bindgen_bitfield_unit.set(0usize, 1u8, { 139 | let isLowMemoryDetectionSupported: u32 = 140 | unsafe { ::std::mem::transmute(isLowMemoryDetectionSupported) }; 141 | isLowMemoryDetectionSupported as u64 142 | }); 143 | __bindgen_bitfield_unit.set(1usize, 1u8, { 144 | let isCompilationTimeMonitoringSupported: u32 = 145 | unsafe { ::std::mem::transmute(isCompilationTimeMonitoringSupported) }; 146 | isCompilationTimeMonitoringSupported as u64 147 | }); 148 | __bindgen_bitfield_unit.set(2usize, 1u8, { 149 | let isThreadContentionMonitoringSupported: u32 = 150 | unsafe { ::std::mem::transmute(isThreadContentionMonitoringSupported) }; 151 | isThreadContentionMonitoringSupported as u64 152 | }); 153 | __bindgen_bitfield_unit.set(3usize, 1u8, { 154 | let isCurrentThreadCpuTimeSupported: u32 = 155 | unsafe { ::std::mem::transmute(isCurrentThreadCpuTimeSupported) }; 156 | isCurrentThreadCpuTimeSupported as u64 157 | }); 158 | __bindgen_bitfield_unit.set(4usize, 1u8, { 159 | let isOtherThreadCpuTimeSupported: u32 = 160 | unsafe { ::std::mem::transmute(isOtherThreadCpuTimeSupported) }; 161 | isOtherThreadCpuTimeSupported as u64 162 | }); 163 | __bindgen_bitfield_unit.set(5usize, 1u8, { 164 | let isObjectMonitorUsageSupported: u32 = 165 | unsafe { ::std::mem::transmute(isObjectMonitorUsageSupported) }; 166 | isObjectMonitorUsageSupported as u64 167 | }); 168 | __bindgen_bitfield_unit.set(6usize, 1u8, { 169 | let isSynchronizerUsageSupported: u32 = 170 | unsafe { ::std::mem::transmute(isSynchronizerUsageSupported) }; 171 | isSynchronizerUsageSupported as u64 172 | }); 173 | __bindgen_bitfield_unit.set(7usize, 1u8, { 174 | let isThreadAllocatedMemorySupported: u32 = 175 | unsafe { ::std::mem::transmute(isThreadAllocatedMemorySupported) }; 176 | isThreadAllocatedMemorySupported as u64 177 | }); 178 | __bindgen_bitfield_unit.set(8usize, 1u8, { 179 | let isRemoteDiagnosticCommandsSupported: u32 = 180 | unsafe { ::std::mem::transmute(isRemoteDiagnosticCommandsSupported) }; 181 | isRemoteDiagnosticCommandsSupported as u64 182 | }); 183 | __bindgen_bitfield_unit 184 | } 185 | } 186 | pub const jmmLongAttribute_JMM_CLASS_LOADED_COUNT: jmmLongAttribute = 1; 187 | pub const jmmLongAttribute_JMM_CLASS_UNLOADED_COUNT: jmmLongAttribute = 2; 188 | pub const jmmLongAttribute_JMM_THREAD_TOTAL_COUNT: jmmLongAttribute = 3; 189 | pub const jmmLongAttribute_JMM_THREAD_LIVE_COUNT: jmmLongAttribute = 4; 190 | pub const jmmLongAttribute_JMM_THREAD_PEAK_COUNT: jmmLongAttribute = 5; 191 | pub const jmmLongAttribute_JMM_THREAD_DAEMON_COUNT: jmmLongAttribute = 6; 192 | pub const jmmLongAttribute_JMM_JVM_INIT_DONE_TIME_MS: jmmLongAttribute = 7; 193 | pub const jmmLongAttribute_JMM_COMPILE_TOTAL_TIME_MS: jmmLongAttribute = 8; 194 | pub const jmmLongAttribute_JMM_GC_TIME_MS: jmmLongAttribute = 9; 195 | pub const jmmLongAttribute_JMM_GC_COUNT: jmmLongAttribute = 10; 196 | pub const jmmLongAttribute_JMM_JVM_UPTIME_MS: jmmLongAttribute = 11; 197 | pub const jmmLongAttribute_JMM_INTERNAL_ATTRIBUTE_INDEX: jmmLongAttribute = 100; 198 | pub const jmmLongAttribute_JMM_CLASS_LOADED_BYTES: jmmLongAttribute = 101; 199 | pub const jmmLongAttribute_JMM_CLASS_UNLOADED_BYTES: jmmLongAttribute = 102; 200 | pub const jmmLongAttribute_JMM_TOTAL_CLASSLOAD_TIME_MS: jmmLongAttribute = 103; 201 | pub const jmmLongAttribute_JMM_VM_GLOBAL_COUNT: jmmLongAttribute = 104; 202 | pub const jmmLongAttribute_JMM_SAFEPOINT_COUNT: jmmLongAttribute = 105; 203 | pub const jmmLongAttribute_JMM_TOTAL_SAFEPOINTSYNC_TIME_MS: jmmLongAttribute = 106; 204 | pub const jmmLongAttribute_JMM_TOTAL_STOPPED_TIME_MS: jmmLongAttribute = 107; 205 | pub const jmmLongAttribute_JMM_TOTAL_APP_TIME_MS: jmmLongAttribute = 108; 206 | pub const jmmLongAttribute_JMM_VM_THREAD_COUNT: jmmLongAttribute = 109; 207 | pub const jmmLongAttribute_JMM_CLASS_INIT_TOTAL_COUNT: jmmLongAttribute = 110; 208 | pub const jmmLongAttribute_JMM_CLASS_INIT_TOTAL_TIME_MS: jmmLongAttribute = 111; 209 | pub const jmmLongAttribute_JMM_METHOD_DATA_SIZE_BYTES: jmmLongAttribute = 112; 210 | pub const jmmLongAttribute_JMM_CLASS_VERIFY_TOTAL_TIME_MS: jmmLongAttribute = 113; 211 | pub const jmmLongAttribute_JMM_SHARED_CLASS_LOADED_COUNT: jmmLongAttribute = 114; 212 | pub const jmmLongAttribute_JMM_SHARED_CLASS_UNLOADED_COUNT: jmmLongAttribute = 115; 213 | pub const jmmLongAttribute_JMM_SHARED_CLASS_LOADED_BYTES: jmmLongAttribute = 116; 214 | pub const jmmLongAttribute_JMM_SHARED_CLASS_UNLOADED_BYTES: jmmLongAttribute = 117; 215 | pub const jmmLongAttribute_JMM_OS_ATTRIBUTE_INDEX: jmmLongAttribute = 200; 216 | pub const jmmLongAttribute_JMM_OS_PROCESS_ID: jmmLongAttribute = 201; 217 | pub const jmmLongAttribute_JMM_OS_MEM_TOTAL_PHYSICAL_BYTES: jmmLongAttribute = 202; 218 | pub const jmmLongAttribute_JMM_GC_EXT_ATTRIBUTE_INFO_SIZE: jmmLongAttribute = 401; 219 | pub type jmmLongAttribute = ::std::os::raw::c_uint; 220 | pub const jmmBoolAttribute_JMM_VERBOSE_GC: jmmBoolAttribute = 21; 221 | pub const jmmBoolAttribute_JMM_VERBOSE_CLASS: jmmBoolAttribute = 22; 222 | pub const jmmBoolAttribute_JMM_THREAD_CONTENTION_MONITORING: jmmBoolAttribute = 23; 223 | pub const jmmBoolAttribute_JMM_THREAD_CPU_TIME: jmmBoolAttribute = 24; 224 | pub const jmmBoolAttribute_JMM_THREAD_ALLOCATED_MEMORY: jmmBoolAttribute = 25; 225 | pub type jmmBoolAttribute = ::std::os::raw::c_uint; 226 | pub const JMM_THREAD_STATE_FLAG_SUSPENDED: ::std::os::raw::c_uint = 1048576; 227 | pub const JMM_THREAD_STATE_FLAG_NATIVE: ::std::os::raw::c_uint = 4194304; 228 | pub const jmmStatisticType_JMM_STAT_PEAK_THREAD_COUNT: jmmStatisticType = 801; 229 | pub const jmmStatisticType_JMM_STAT_THREAD_CONTENTION_COUNT: jmmStatisticType = 802; 230 | pub const jmmStatisticType_JMM_STAT_THREAD_CONTENTION_TIME: jmmStatisticType = 803; 231 | pub const jmmStatisticType_JMM_STAT_THREAD_CONTENTION_STAT: jmmStatisticType = 804; 232 | pub const jmmStatisticType_JMM_STAT_PEAK_POOL_USAGE: jmmStatisticType = 805; 233 | pub const jmmStatisticType_JMM_STAT_GC_STAT: jmmStatisticType = 806; 234 | pub type jmmStatisticType = ::std::os::raw::c_uint; 235 | pub const jmmThresholdType_JMM_USAGE_THRESHOLD_HIGH: jmmThresholdType = 901; 236 | pub const jmmThresholdType_JMM_USAGE_THRESHOLD_LOW: jmmThresholdType = 902; 237 | pub const jmmThresholdType_JMM_COLLECTION_USAGE_THRESHOLD_HIGH: jmmThresholdType = 903; 238 | pub const jmmThresholdType_JMM_COLLECTION_USAGE_THRESHOLD_LOW: jmmThresholdType = 904; 239 | pub type jmmThresholdType = ::std::os::raw::c_uint; 240 | pub const jmmVMGlobalType_JMM_VMGLOBAL_TYPE_UNKNOWN: jmmVMGlobalType = 0; 241 | pub const jmmVMGlobalType_JMM_VMGLOBAL_TYPE_JBOOLEAN: jmmVMGlobalType = 1; 242 | pub const jmmVMGlobalType_JMM_VMGLOBAL_TYPE_JSTRING: jmmVMGlobalType = 2; 243 | pub const jmmVMGlobalType_JMM_VMGLOBAL_TYPE_JLONG: jmmVMGlobalType = 3; 244 | pub const jmmVMGlobalType_JMM_VMGLOBAL_TYPE_JDOUBLE: jmmVMGlobalType = 4; 245 | pub type jmmVMGlobalType = ::std::os::raw::c_uint; 246 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_DEFAULT: jmmVMGlobalOrigin = 1; 247 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_COMMAND_LINE: jmmVMGlobalOrigin = 2; 248 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_MANAGEMENT: jmmVMGlobalOrigin = 3; 249 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR: jmmVMGlobalOrigin = 4; 250 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_CONFIG_FILE: jmmVMGlobalOrigin = 5; 251 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_ERGONOMIC: jmmVMGlobalOrigin = 6; 252 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND: jmmVMGlobalOrigin = 7; 253 | pub const jmmVMGlobalOrigin_JMM_VMGLOBAL_ORIGIN_OTHER: jmmVMGlobalOrigin = 99; 254 | pub type jmmVMGlobalOrigin = ::std::os::raw::c_uint; 255 | #[repr(C)] 256 | #[derive(Copy, Clone)] 257 | pub struct jmmVMGlobal { 258 | pub name: jstring, 259 | pub value: jvalue, 260 | pub type_: jmmVMGlobalType, 261 | pub origin: jmmVMGlobalOrigin, 262 | pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>, 263 | pub reserved1: *mut ::std::os::raw::c_void, 264 | pub reserved2: *mut ::std::os::raw::c_void, 265 | } 266 | impl jmmVMGlobal { 267 | #[inline] 268 | pub fn writeable(&self) -> ::std::os::raw::c_uint { 269 | unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } 270 | } 271 | #[inline] 272 | pub fn set_writeable(&mut self, val: ::std::os::raw::c_uint) { 273 | unsafe { 274 | let val: u32 = ::std::mem::transmute(val); 275 | self._bitfield_1.set(0usize, 1u8, val as u64) 276 | } 277 | } 278 | #[inline] 279 | pub fn external(&self) -> ::std::os::raw::c_uint { 280 | unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) } 281 | } 282 | #[inline] 283 | pub fn set_external(&mut self, val: ::std::os::raw::c_uint) { 284 | unsafe { 285 | let val: u32 = ::std::mem::transmute(val); 286 | self._bitfield_1.set(1usize, 1u8, val as u64) 287 | } 288 | } 289 | #[inline] 290 | pub fn reserved(&self) -> ::std::os::raw::c_uint { 291 | unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 30u8) as u32) } 292 | } 293 | #[inline] 294 | pub fn set_reserved(&mut self, val: ::std::os::raw::c_uint) { 295 | unsafe { 296 | let val: u32 = ::std::mem::transmute(val); 297 | self._bitfield_1.set(2usize, 30u8, val as u64) 298 | } 299 | } 300 | #[inline] 301 | pub fn new_bitfield_1( 302 | writeable: ::std::os::raw::c_uint, 303 | external: ::std::os::raw::c_uint, 304 | reserved: ::std::os::raw::c_uint, 305 | ) -> __BindgenBitfieldUnit<[u8; 4usize], u32> { 306 | let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u32> = 307 | Default::default(); 308 | __bindgen_bitfield_unit.set(0usize, 1u8, { 309 | let writeable: u32 = unsafe { ::std::mem::transmute(writeable) }; 310 | writeable as u64 311 | }); 312 | __bindgen_bitfield_unit.set(1usize, 1u8, { 313 | let external: u32 = unsafe { ::std::mem::transmute(external) }; 314 | external as u64 315 | }); 316 | __bindgen_bitfield_unit.set(2usize, 30u8, { 317 | let reserved: u32 = unsafe { ::std::mem::transmute(reserved) }; 318 | reserved as u64 319 | }); 320 | __bindgen_bitfield_unit 321 | } 322 | } 323 | #[repr(C)] 324 | #[derive(Debug, Copy, Clone)] 325 | pub struct jmmExtAttributeInfo { 326 | pub name: *const ::std::os::raw::c_char, 327 | pub type_: ::std::os::raw::c_char, 328 | pub description: *const ::std::os::raw::c_char, 329 | } 330 | #[repr(C)] 331 | #[derive(Debug, Copy, Clone)] 332 | pub struct jmmGCStat { 333 | pub gc_index: jlong, 334 | pub start_time: jlong, 335 | pub end_time: jlong, 336 | pub usage_before_gc: jobjectArray, 337 | pub usage_after_gc: jobjectArray, 338 | pub gc_ext_attribute_values_size: jint, 339 | pub gc_ext_attribute_values: *mut jvalue, 340 | pub num_gc_ext_attributes: jint, 341 | } 342 | #[repr(C)] 343 | #[derive(Debug, Copy, Clone)] 344 | pub struct dcmdInfo { 345 | pub name: *const ::std::os::raw::c_char, 346 | pub description: *const ::std::os::raw::c_char, 347 | pub impact: *const ::std::os::raw::c_char, 348 | pub permission_class: *const ::std::os::raw::c_char, 349 | pub permission_name: *const ::std::os::raw::c_char, 350 | pub permission_action: *const ::std::os::raw::c_char, 351 | pub num_arguments: ::std::os::raw::c_int, 352 | pub enabled: jboolean, 353 | } 354 | #[repr(C)] 355 | #[derive(Debug, Copy, Clone)] 356 | pub struct dcmdArgInfo { 357 | pub name: *const ::std::os::raw::c_char, 358 | pub description: *const ::std::os::raw::c_char, 359 | pub type_: *const ::std::os::raw::c_char, 360 | pub default_string: *const ::std::os::raw::c_char, 361 | pub mandatory: jboolean, 362 | pub option: jboolean, 363 | pub multiple: jboolean, 364 | pub position: ::std::os::raw::c_int, 365 | } 366 | #[repr(C)] 367 | #[derive(Debug, Copy, Clone)] 368 | pub struct jmmInterface_1_ { 369 | pub reserved1: *mut ::std::os::raw::c_void, 370 | pub reserved2: *mut ::std::os::raw::c_void, 371 | pub GetVersion: ::std::option::Option jint>, 372 | pub GetOptionalSupport: ::std::option::Option< 373 | unsafe extern "C" fn(env: *mut JNIEnv, support_ptr: *mut jmmOptionalSupport) -> jint, 374 | >, 375 | pub GetThreadInfo: ::std::option::Option< 376 | unsafe extern "C" fn( 377 | env: *mut JNIEnv, 378 | ids: jlongArray, 379 | maxDepth: jint, 380 | infoArray: jobjectArray, 381 | ) -> jint, 382 | >, 383 | pub GetMemoryPools: 384 | ::std::option::Option jobjectArray>, 385 | pub GetMemoryManagers: ::std::option::Option< 386 | unsafe extern "C" fn(env: *mut JNIEnv, pool: jobject) -> jobjectArray, 387 | >, 388 | pub GetMemoryPoolUsage: 389 | ::std::option::Option jobject>, 390 | pub GetPeakMemoryPoolUsage: 391 | ::std::option::Option jobject>, 392 | pub GetOneThreadAllocatedMemory: 393 | ::std::option::Option jlong>, 394 | pub GetThreadAllocatedMemory: ::std::option::Option< 395 | unsafe extern "C" fn(env: *mut JNIEnv, ids: jlongArray, sizeArray: jlongArray), 396 | >, 397 | pub GetMemoryUsage: 398 | ::std::option::Option jobject>, 399 | pub GetLongAttribute: ::std::option::Option< 400 | unsafe extern "C" fn(env: *mut JNIEnv, obj: jobject, att: jmmLongAttribute) -> jlong, 401 | >, 402 | pub GetBoolAttribute: ::std::option::Option< 403 | unsafe extern "C" fn(env: *mut JNIEnv, att: jmmBoolAttribute) -> jboolean, 404 | >, 405 | pub SetBoolAttribute: ::std::option::Option< 406 | unsafe extern "C" fn(env: *mut JNIEnv, att: jmmBoolAttribute, flag: jboolean) -> jboolean, 407 | >, 408 | pub GetLongAttributes: ::std::option::Option< 409 | unsafe extern "C" fn( 410 | env: *mut JNIEnv, 411 | obj: jobject, 412 | atts: *mut jmmLongAttribute, 413 | count: jint, 414 | result: *mut jlong, 415 | ) -> jint, 416 | >, 417 | pub FindCircularBlockedThreads: 418 | ::std::option::Option jobjectArray>, 419 | pub GetThreadCpuTime: 420 | ::std::option::Option jlong>, 421 | pub GetVMGlobalNames: 422 | ::std::option::Option jobjectArray>, 423 | pub GetVMGlobals: ::std::option::Option< 424 | unsafe extern "C" fn( 425 | env: *mut JNIEnv, 426 | names: jobjectArray, 427 | globals: *mut jmmVMGlobal, 428 | count: jint, 429 | ) -> jint, 430 | >, 431 | pub GetInternalThreadTimes: ::std::option::Option< 432 | unsafe extern "C" fn(env: *mut JNIEnv, names: jobjectArray, times: jlongArray) -> jint, 433 | >, 434 | pub ResetStatistic: ::std::option::Option< 435 | unsafe extern "C" fn(env: *mut JNIEnv, obj: jvalue, type_: jmmStatisticType) -> jboolean, 436 | >, 437 | pub SetPoolSensor: ::std::option::Option< 438 | unsafe extern "C" fn( 439 | env: *mut JNIEnv, 440 | pool: jobject, 441 | type_: jmmThresholdType, 442 | sensor: jobject, 443 | ), 444 | >, 445 | pub SetPoolThreshold: ::std::option::Option< 446 | unsafe extern "C" fn( 447 | env: *mut JNIEnv, 448 | pool: jobject, 449 | type_: jmmThresholdType, 450 | threshold: jlong, 451 | ) -> jlong, 452 | >, 453 | pub GetPoolCollectionUsage: 454 | ::std::option::Option jobject>, 455 | pub GetGCExtAttributeInfo: ::std::option::Option< 456 | unsafe extern "C" fn( 457 | env: *mut JNIEnv, 458 | mgr: jobject, 459 | ext_info: *mut jmmExtAttributeInfo, 460 | count: jint, 461 | ) -> jint, 462 | >, 463 | pub GetLastGCStat: ::std::option::Option< 464 | unsafe extern "C" fn(env: *mut JNIEnv, mgr: jobject, gc_stat: *mut jmmGCStat), 465 | >, 466 | pub GetThreadCpuTimeWithKind: ::std::option::Option< 467 | unsafe extern "C" fn( 468 | env: *mut JNIEnv, 469 | thread_id: jlong, 470 | user_sys_cpu_time: jboolean, 471 | ) -> jlong, 472 | >, 473 | pub GetThreadCpuTimesWithKind: ::std::option::Option< 474 | unsafe extern "C" fn( 475 | env: *mut JNIEnv, 476 | ids: jlongArray, 477 | timeArray: jlongArray, 478 | user_sys_cpu_time: jboolean, 479 | ), 480 | >, 481 | pub DumpHeap0: ::std::option::Option< 482 | unsafe extern "C" fn(env: *mut JNIEnv, outputfile: jstring, live: jboolean) -> jint, 483 | >, 484 | pub FindDeadlocks: ::std::option::Option< 485 | unsafe extern "C" fn(env: *mut JNIEnv, object_monitors_only: jboolean) -> jobjectArray, 486 | >, 487 | pub SetVMGlobal: ::std::option::Option< 488 | unsafe extern "C" fn(env: *mut JNIEnv, flag_name: jstring, new_value: jvalue), 489 | >, 490 | pub reserved6: *mut ::std::os::raw::c_void, 491 | pub DumpThreads: ::std::option::Option< 492 | unsafe extern "C" fn( 493 | env: *mut JNIEnv, 494 | ids: jlongArray, 495 | lockedMonitors: jboolean, 496 | lockedSynchronizers: jboolean, 497 | maxDepth: jint, 498 | ) -> jobjectArray, 499 | >, 500 | pub SetGCNotificationEnabled: ::std::option::Option< 501 | unsafe extern "C" fn(env: *mut JNIEnv, mgr: jobject, enabled: jboolean), 502 | >, 503 | pub GetDiagnosticCommands: 504 | ::std::option::Option jobjectArray>, 505 | pub GetDiagnosticCommandInfo: ::std::option::Option< 506 | unsafe extern "C" fn(env: *mut JNIEnv, cmds: jobjectArray, infoArray: *mut dcmdInfo), 507 | >, 508 | pub GetDiagnosticCommandArgumentsInfo: ::std::option::Option< 509 | unsafe extern "C" fn(env: *mut JNIEnv, commandName: jstring, infoArray: *mut dcmdArgInfo), 510 | >, 511 | pub ExecuteDiagnosticCommand: 512 | ::std::option::Option jstring>, 513 | pub SetDiagnosticFrameworkNotificationEnabled: 514 | ::std::option::Option, 515 | } 516 | pub type JmmInterface = jmmInterface_1_; 517 | -------------------------------------------------------------------------------- /src/jvmticmlr.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(dead_code)] 5 | 6 | use crate::jni::*; 7 | 8 | pub const JVMTI_CMLR_MAJOR_VERSION_1: ::std::os::raw::c_uint = 1; 9 | pub const JVMTI_CMLR_MINOR_VERSION_0: ::std::os::raw::c_uint = 0; 10 | pub const JVMTI_CMLR_MAJOR_VERSION: ::std::os::raw::c_uint = 1; 11 | pub const JVMTI_CMLR_MINOR_VERSION: ::std::os::raw::c_uint = 0; 12 | pub const jvmtiCMLRKind_JVMTI_CMLR_DUMMY: jvmtiCMLRKind = 1; 13 | pub const jvmtiCMLRKind_JVMTI_CMLR_INLINE_INFO: jvmtiCMLRKind = 2; 14 | pub type jvmtiCMLRKind = ::std::os::raw::c_uint; 15 | #[repr(C)] 16 | #[derive(Debug, Copy, Clone)] 17 | pub struct _jvmtiCompiledMethodLoadRecordHeader { 18 | pub kind: jvmtiCMLRKind, 19 | pub majorinfoversion: jint, 20 | pub minorinfoversion: jint, 21 | pub next: *mut _jvmtiCompiledMethodLoadRecordHeader, 22 | } 23 | pub type jvmtiCompiledMethodLoadRecordHeader = _jvmtiCompiledMethodLoadRecordHeader; 24 | #[repr(C)] 25 | #[derive(Debug, Copy, Clone)] 26 | pub struct _PCStackInfo { 27 | pub pc: *mut ::std::os::raw::c_void, 28 | pub numstackframes: jint, 29 | pub methods: *mut jmethodID, 30 | pub bcis: *mut jint, 31 | } 32 | pub type PCStackInfo = _PCStackInfo; 33 | #[repr(C)] 34 | #[derive(Debug, Copy, Clone)] 35 | pub struct _jvmtiCompiledMethodLoadInlineRecord { 36 | pub header: jvmtiCompiledMethodLoadRecordHeader, 37 | pub numpcs: jint, 38 | pub pcinfo: *mut PCStackInfo, 39 | } 40 | pub type jvmtiCompiledMethodLoadInlineRecord = _jvmtiCompiledMethodLoadInlineRecord; 41 | #[repr(C)] 42 | #[derive(Copy, Clone)] 43 | pub struct _jvmtiCompiledMethodLoadDummyRecord { 44 | pub header: jvmtiCompiledMethodLoadRecordHeader, 45 | pub message: [::std::os::raw::c_char; 50usize], 46 | } 47 | pub type jvmtiCompiledMethodLoadDummyRecord = _jvmtiCompiledMethodLoadDummyRecord; 48 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | mod bitfield; 2 | pub mod weak; 3 | pub mod varargs; 4 | 5 | pub mod classfile_constants; 6 | pub mod jawt; 7 | pub mod jdwpTransport; 8 | pub mod jmm; 9 | pub mod jni; 10 | pub mod jvm; 11 | pub mod jvmti; 12 | pub mod jvmticmlr; 13 | 14 | -------------------------------------------------------------------------------- /src/varargs.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(dead_code)] 5 | 6 | pub type __builtin_va_list = [__va_list_tag; 1usize]; 7 | #[repr(C)] 8 | #[derive(Debug, Copy, Clone)] 9 | pub struct __va_list_tag { 10 | pub gp_offset: ::std::os::raw::c_uint, 11 | pub fp_offset: ::std::os::raw::c_uint, 12 | pub overflow_arg_area: *mut ::std::os::raw::c_void, 13 | pub reg_save_area: *mut ::std::os::raw::c_void, 14 | } 15 | -------------------------------------------------------------------------------- /src/weak.rs: -------------------------------------------------------------------------------- 1 | use std::sync::atomic::{AtomicUsize, Ordering}; 2 | use std::{marker, mem}; 3 | use std::ffi::CString; 4 | use std::os::raw::{c_char, c_void}; 5 | 6 | pub struct Weak { 7 | name: &'static str, 8 | addr: AtomicUsize, 9 | _marker: marker::PhantomData, 10 | } 11 | 12 | impl Weak { 13 | pub const fn new(name: &'static str) -> Weak { 14 | Weak { 15 | name, 16 | addr: AtomicUsize::new(1), 17 | _marker: marker::PhantomData, 18 | } 19 | } 20 | 21 | pub fn get(&self) -> Option<&F> { 22 | assert_eq!(mem::size_of::(), mem::size_of::()); 23 | unsafe { 24 | if self.addr.load(Ordering::SeqCst) == 1 { 25 | self.addr.store(fetch(self.name), Ordering::SeqCst); 26 | } 27 | if self.addr.load(Ordering::SeqCst) == 0 { 28 | None 29 | } else { 30 | mem::transmute::<&AtomicUsize, Option<&F>>(&self.addr) 31 | } 32 | } 33 | } 34 | } 35 | 36 | unsafe fn fetch(name: &str) -> usize { 37 | let name = match CString::new(name) { 38 | Ok(cstr) => cstr, 39 | Err(..) => return 0, 40 | }; 41 | find_symbol(name.as_ptr()) 42 | } 43 | 44 | #[cfg(unix)] 45 | unsafe fn find_symbol(name: *const c_char) -> usize { 46 | extern "C" { 47 | pub fn dlsym( 48 | handle: *mut c_void, 49 | symbol: *const c_char, 50 | ) -> *mut c_void; 51 | } 52 | pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; 53 | 54 | dlsym(RTLD_DEFAULT, name) as usize 55 | } 56 | 57 | #[cfg(windows)] 58 | unsafe fn find_symbol(name: *const c_char) -> usize { 59 | use std::ptr::null; 60 | use winapi::um::libloaderapi::{GetModuleHandleA, GetProcAddress}; 61 | GetProcAddress(GetModuleHandleA(null()), name) as usize 62 | } 63 | --------------------------------------------------------------------------------