Skip to content
Commits on Source (6)
......@@ -17,8 +17,7 @@ language: java
sudo: false
jdk:
- openjdk7
- oraclejdk8
after_success:
- mvn clean cobertura:cobertura coveralls:report
- mvn -Ddoclint:none clean cobertura:cobertura coveralls:report
<!---
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!---
+======================================================================+
|**** ****|
|**** THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN ****|
|**** DO NOT EDIT DIRECTLY ****|
|**** ****|
+======================================================================+
| TEMPLATE FILE: contributing-md-template.md |
| commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+======================================================================+
| |
| 1) Re-generate using: mvn commons:contributing-md |
| |
| 2) Set the following properties in the component's pom: |
| - commons.jira.id (required, alphabetic, upper case) |
| |
| 3) Example Properties |
| |
| <properties> |
| <commons.jira.id>MATH</commons.jira.id> |
| </properties> |
| |
+======================================================================+
--->
Contributing to Apache Commons BCEL
======================
You have found a bug or you have an idea for a cool new feature? Contributing code is a great way to give something back to
the open source community. Before you dig right into the code there are a few guidelines that we need contributors to
follow so that we can have a chance of keeping on top of things.
Getting Started
---------------
+ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
+ Make sure you have a [GitHub account](https://github.com/signup/free).
+ If you're planning to implement a new feature it makes sense to discuss you're changes on the [dev list](https://commons.apache.org/mail-lists.html) first. This way you can make sure you're not wasting your time on something that isn't considered to be in Apache Commons BCEL's scope.
+ Submit a [Jira Ticket][jira] for your issue, assuming one does not already exist.
+ Clearly describe the issue including steps to reproduce when it is a bug.
+ Make sure you fill in the earliest version that you know has the issue.
+ Find the corresponding [repository on GitHub](https://github.com/apache/?query=commons-),
[fork](https://help.github.com/articles/fork-a-repo/) and check out your forked repository.
Making Changes
--------------
+ Create a _topic branch_ for your isolated work.
* Usually you should base your branch on the `master` or `trunk` branch.
* A good topic branch name can be the JIRA bug id plus a keyword, e.g. `BCEL-123-InputStream`.
* If you have submitted multiple JIRA issues, try to maintain separate branches and pull requests.
+ Make commits of logical units.
* Make sure your commit messages are meaningful and in the proper format. Your commit message should contain the key of the JIRA issue.
* e.g. `BCEL-123: Close input stream earlier`
+ Respect the original code style:
+ Only use spaces for indentation.
+ Create minimal diffs - disable _On Save_ actions like _Reformat Source Code_ or _Organize Imports_. If you feel the source code should be reformatted create a separate PR for this change first.
+ Check for unnecessary whitespace with `git diff` -- check before committing.
+ Make sure you have added the necessary tests for your changes, typically in `src/test/java`.
+ Run all the tests with `mvn clean verify` to assure nothing else was accidentally broken.
Making Trivial Changes
----------------------
The JIRA tickets are used to generate the changelog for the next release.
For changes of a trivial nature to comments and documentation, it is not always necessary to create a new ticket in JIRA.
In this case, it is appropriate to start the first line of a commit with '(doc)' instead of a ticket number.
Submitting Changes
------------------
+ Sign and submit the Apache [Contributor License Agreement][cla] if you haven't already.
* Note that small patches & typical bug fixes do not require a CLA as
clause 5 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0.html#contributions)
covers them.
+ Push your changes to a topic branch in your fork of the repository.
+ Submit a _Pull Request_ to the corresponding repository in the `apache` organization.
* Verify _Files Changed_ shows only your intended changes and does not
include additional files like `target/*.class`
+ Update your JIRA ticket and include a link to the pull request in the ticket.
If you prefer to not use GitHub, then you can instead use
`git format-patch` (or `svn diff`) and attach the patch file to the JIRA issue.
Additional Resources
--------------------
+ [Contributing patches](https://commons.apache.org/patches.html)
+ [Apache Commons BCEL JIRA project page][jira]
+ [Contributor License Agreement][cla]
+ [General GitHub documentation](https://help.github.com/)
+ [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
+ `#apache-commons` IRC channel on `irc.freenode.net`
[cla]:https://www.apache.org/licenses/#clas
[jira]:https://issues.apache.org/jira/browse/BCEL
<!---
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!---
+======================================================================+
|**** ****|
|**** THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN ****|
|**** DO NOT EDIT DIRECTLY ****|
|**** ****|
+======================================================================+
| TEMPLATE FILE: contributing-md-template.md |
| commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+======================================================================+
| |
| 1) Re-generate using: mvn commons-build:contributing-md |
| |
| 2) Set the following properties in the component's pom: |
| - commons.jira.id (required, alphabetic, upper case) |
| |
| 3) Example Properties |
| |
| <properties> |
| <commons.jira.id>MATH</commons.jira.id> |
| </properties> |
| |
+======================================================================+
--->
Contributing to Apache Commons BCEL
======================
You have found a bug or you have an idea for a cool new feature? Contributing code is a great way to give something back to
the open source community. Before you dig right into the code there are a few guidelines that we need contributors to
follow so that we can have a chance of keeping on top of things.
Getting Started
---------------
+ Make sure you have a [JIRA account](https://issues.apache.org/jira/).
+ Make sure you have a [GitHub account](https://github.com/signup/free).
+ If you're planning to implement a new feature it makes sense to discuss your changes on the [dev list](https://commons.apache.org/mail-lists.html) first. This way you can make sure you're not wasting your time on something that isn't considered to be in Apache Commons BCEL's scope.
+ Submit a [Jira Ticket][jira] for your issue, assuming one does not already exist.
+ Clearly describe the issue including steps to reproduce when it is a bug.
+ Make sure you fill in the earliest version that you know has the issue.
+ Find the corresponding [repository on GitHub](https://github.com/apache/?query=commons-),
[fork](https://help.github.com/articles/fork-a-repo/) and check out your forked repository.
Making Changes
--------------
+ Create a _topic branch_ for your isolated work.
* Usually you should base your branch on the `master` or `trunk` branch.
* A good topic branch name can be the JIRA bug id plus a keyword, e.g. `BCEL-123-InputStream`.
* If you have submitted multiple JIRA issues, try to maintain separate branches and pull requests.
+ Make commits of logical units.
* Make sure your commit messages are meaningful and in the proper format. Your commit message should contain the key of the JIRA issue.
* e.g. `BCEL-123: Close input stream earlier`
+ Respect the original code style:
+ Only use spaces for indentation.
+ Create minimal diffs - disable _On Save_ actions like _Reformat Source Code_ or _Organize Imports_. If you feel the source code should be reformatted create a separate PR for this change first.
+ Check for unnecessary whitespace with `git diff` -- check before committing.
+ Make sure you have added the necessary tests for your changes, typically in `src/test/java`.
+ Run all the tests with `mvn clean verify` to assure nothing else was accidentally broken.
Making Trivial Changes
----------------------
The JIRA tickets are used to generate the changelog for the next release.
For changes of a trivial nature to comments and documentation, it is not always necessary to create a new ticket in JIRA.
In this case, it is appropriate to start the first line of a commit with '(doc)' instead of a ticket number.
Submitting Changes
------------------
+ Sign and submit the Apache [Contributor License Agreement][cla] if you haven't already.
* Note that small patches & typical bug fixes do not require a CLA as
clause 5 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0.html#contributions)
covers them.
+ Push your changes to a topic branch in your fork of the repository.
+ Submit a _Pull Request_ to the corresponding repository in the `apache` organization.
* Verify _Files Changed_ shows only your intended changes and does not
include additional files like `target/*.class`
+ Update your JIRA ticket and include a link to the pull request in the ticket.
If you prefer to not use GitHub, then you can instead use
`git format-patch` (or `svn diff`) and attach the patch file to the JIRA issue.
Additional Resources
--------------------
+ [Contributing patches](https://commons.apache.org/patches.html)
+ [Apache Commons BCEL JIRA project page][jira]
+ [Contributor License Agreement][cla]
+ [General GitHub documentation](https://help.github.com/)
+ [GitHub pull request documentation](https://help.github.com/articles/creating-a-pull-request/)
+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
+ `#apache-commons` IRC channel on `irc.freenode.net`
[cla]:https://www.apache.org/licenses/#clas
[jira]:https://issues.apache.org/jira/browse/BCEL
Apache Commons BCEL
Copyright 2004-2017 The Apache Software Foundation
Copyright 2004-2019 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
......@@ -25,7 +25,7 @@
| commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+======================================================================+
| |
| 1) Re-generate using: mvn commons:readme-md |
| 1) Re-generate using: mvn commons-build:readme-md |
| |
| 2) Set the following properties in the component's pom: |
| - commons.componentid (required, alphabetic, lower case) |
......@@ -43,10 +43,10 @@
Apache Commons BCEL
===================
[![Build Status](https://travis-ci.org/apache/bcel.svg?branch=master)](https://travis-ci.org/apache/bcel)
[![Coverage Status](https://coveralls.io/repos/apache/bcel/badge.svg?branch=master)](https://coveralls.io/r/apache/bcel)
[![Build Status](https://travis-ci.org/apache/commons-bcel.svg)](https://travis-ci.org/apache/commons-bcel)
[![Coverage Status](https://coveralls.io/repos/apache/commons-bcel/badge.svg)](https://coveralls.io/r/apache/commons-bcel)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
[![Javadocs](https://javadoc.io/badge/org.apache.bcel/bcel/6.3.svg)](https://javadoc.io/doc/org.apache.bcel/bcel/6.3)
Apache Commons Bytecode Engineering Library
......@@ -54,7 +54,7 @@ Documentation
-------------
More information can be found on the [Apache Commons BCEL homepage](https://commons.apache.org/proper/commons-bcel).
The [JavaDoc](https://commons.apache.org/proper/commons-bcel/javadocs/api-release) can be browsed.
The [Javadoc](https://commons.apache.org/proper/commons-bcel/javadocs/api-release) can be browsed.
Questions related to the usage of Apache Commons BCEL should be posted to the [user mailing list][ml].
Where can I get the latest release?
......@@ -67,7 +67,7 @@ Alternatively you can pull it from the central Maven repositories:
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.2</version>
<version>6.3</version>
</dependency>
```
......
Apache Commons BCEL
Version 6.3-SNAPSHOT
RELEASE NOTES
INTRODUCTION:
The Apache Commons BCEL team is pleased to announce the release of
Apache Commons BCEL 6.3-SNAPSHOT!
The Byte Code Engineering Library (BCEL) is intended to give users a convenient
way to analyze, create, and manipulate compiled .class files. Classes are
represented by objects containing all the symbolic information of the given
class: methods, fields and byte code instructions.
?
NEW FEATURES:
=============
o Added org.apache.bcel.classfile.Visitor.visitConstantDynamic(ConstantDynamic) Thanks to Mark Thomas.
o Added org.apache.bcel.classfile.ConstantDynamic Thanks to Mark Thomas.
o Added fields in org.apache.bcel.Const for Java 9, 10, and 11. Thanks to Mark Thomas.
o Added fields in org.apache.bcel.Const for Java 12 and 13 based on Java Early Access releases. Thanks to Mark Thomas.
FIXED BUGS:
===========
o BCEL-304: ClassPath.getClassFile() and friends do not work with JDK 9 and higher (PR #22.) Thanks to Gary Gregory, Ed Pavlak.
o BCEL-305: ClassPath.getClassFile() and friends do not work with JRE 9 and higher Thanks to Gary Gregory.
CHANGES:
========
o Initial support for Java 11 Thanks to Mark Thomas, Gary Gregory.
o Update Java requirement from Java 7 to Java 8. Thanks to Gary Gregory.
Have fun!
-Apache Commons BCEL team
Feedback
--------
Open source works best when you give feedback:
http://commons.apache.org/bcel
Please direct all bug reports to JIRA:
https://issues.apache.org/jira/browse/BCEL
Or subscribe to the commons-user mailing list
The Apache Commons Team
-----------------------------------------------------------------------------
Apache Commons BCEL
Version 6.2
RELEASE NOTES
......
bcel (6.3-1) unstable; urgency=medium
* Team upload.
* New upstream release
* Standards-Version updated to 4.4.0
* Use salsa.debian.org Vcs-* URLs
-- Emmanuel Bourg <ebourg@apache.org> Fri, 19 Jul 2019 13:38:29 +0200
bcel (6.2-1) unstable; urgency=medium
* Team upload.
......
......@@ -12,9 +12,9 @@ Build-Depends:
libmaven-javadoc-plugin-java,
junit4,
maven-debian-helper (>= 2.1~)
Standards-Version: 4.1.3
Vcs-Git: https://anonscm.debian.org/git/pkg-java/bcel.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/bcel.git
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/bcel.git
Vcs-Browser: https://salsa.debian.org/java-team/bcel
Homepage: http://commons.apache.org/bcel/
Package: libbcel-java
......
#!/usr/bin/make -f
%:
dh $@ --buildsystem=maven
dh $@
override_dh_installchangelogs:
dh_installchangelogs -- RELEASE-NOTES.txt
get-orig-source:
uscan --download-current-version --force-download --rename
......@@ -27,13 +27,13 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
<version>42</version>
<version>47</version>
</parent>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<packaging>jar</packaging>
<version>6.2</version>
<version>6.3</version>
<name>Apache Commons BCEL</name>
<description>Apache Commons Bytecode Engineering Library</description>
......@@ -43,13 +43,19 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<commons.componentid>bcel</commons.componentid>
<commons.module.name>org.apache.bcel</commons.module.name>
<commons.release.version>6.2</commons.release.version>
<commons.release.desc>(Java 7+)</commons.release.desc>
<commons.release.version>6.3</commons.release.version>
<commons.release.isDistModule>true</commons.release.isDistModule>
<commons.rc.version>RC1</commons.rc.version>
<commons.bc.version>6.2</commons.bc.version>
<commons.release.desc>(Java 8)</commons.release.desc>
<commons.scmPubUrl>https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-bcel</commons.scmPubUrl>
<commons.distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid}</commons.distSvnStagingUrl>
<commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>
<commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
<!-- Configuration properties for the OSGi maven-bundle-plugin -->
<commons.osgi.symbolicName>org.apache.${commons.componentid}</commons.osgi.symbolicName>
<commons.osgi.export>org.apache.bcel.*;version=${project.version};-noimport:=true</commons.osgi.export>
......@@ -59,6 +65,7 @@
<commons.jira.id>BCEL</commons.jira.id>
<commons.jira.pid>12314220</commons.jira.pid>
<commons.findbugs.version>3.0.5</commons.findbugs.version>
<commons.surefire.version>3.0.0-M3</commons.surefire.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<commons.clirr.version>2.8</commons.clirr.version>
<jna.version>4.5.0</jna.version>
......@@ -442,7 +449,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
......@@ -518,7 +525,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
<version>4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
......@@ -568,16 +575,7 @@
</plugins>
</build>
</profile>
<profile>
<id>jdk8-javadoc</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
</profiles>
</project>
......@@ -62,7 +62,18 @@ The <action> type attribute can be add,update,fix,remove.
-->
<body>
<release version="6.2" date="2017-12-DD" description="Experimental Java 9 Support">
<release version="6.3" date="2019-01-24" description="Experimental Java 9, 10, 11, 12-EA, and 13-EA Support">
<action issue="BCEL-304" type="fix" dev="ggregory" due-to="Gary Gregory, Ed Pavlak">ClassPath.getClassFile() and friends do not work with JDK 9 and higher (PR #22.)</action>
<action issue="BCEL-305" type="fix" dev="ggregory" due-to="Gary Gregory">ClassPath.getClassFile() and friends do not work with JRE 9 and higher</action>
<action type="update" dev="ggregory" due-to="Mark Thomas, Gary Gregory">Initial support for Java 11</action>
<action type="add" dev="ggregory" due-to="Mark Thomas">Added org.apache.bcel.classfile.Visitor.visitConstantDynamic(ConstantDynamic)</action>
<action type="add" dev="ggregory" due-to="Mark Thomas">Added org.apache.bcel.classfile.ConstantDynamic</action>
<action type="add" dev="ggregory" due-to="Mark Thomas">Added fields in org.apache.bcel.Const for Java 9, 10, and 11.</action>
<action type="add" dev="ggregory" due-to="Mark Thomas">Added fields in org.apache.bcel.Const for Java 12 and 13 based on Java Early Access releases.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Update Java requirement from Java 7 to Java 8.</action>
</release>
<release version="6.2" date="2017-12-08" description="Experimental Java 9 Support">
<action issue="BCEL-294" type="fix" dev="britter" due-to="Mark Roberts">Incorrect comment in StackMap.java</action>
<action issue="BCEL-296" type="fix" dev="ggregory" due-to="Mark Roberts">Incorrect comment in several classes.</action>
<action issue="BCEL-295" type="fix" dev="ggregory" due-to="Mark Roberts">Fix local variable live range length; add test case.</action>
......
......@@ -111,20 +111,72 @@ public final class Const {
* */
public static final short MAJOR_1_8 = 52;
/** Major version number of class files for Java 1.9.
* @see #MINOR_1_9
* */
public static final short MAJOR_1_9 = 53;
/** Minor version number of class files for Java 1.8.
* @see #MAJOR_1_8
* */
public static final short MINOR_1_8 = 0;
/** Minor version number of class files for Java 1.9.
* @see #MAJOR_1_9
/** Major version number of class files for Java 9.
* @see #MINOR_9
* */
public static final short MAJOR_9 = 53;
/** Minor version number of class files for Java 9.
* @see #MAJOR_9
* */
public static final short MINOR_9 = 0;
/**
* @deprecated Use {@link #MAJOR_9} instead
*/
@Deprecated
public static final short MAJOR_1_9 = MAJOR_9;
/**
* @deprecated Use {@link #MINOR_9} instead
*/
@Deprecated
public static final short MINOR_1_9 = MINOR_9;
/** Major version number of class files for Java 10.
* @see #MINOR_10
* */
public static final short MAJOR_10 = 54;
/** Minor version number of class files for Java 10.
* @see #MAJOR_10
* */
public static final short MINOR_10 = 0;
/** Major version number of class files for Java 11.
* @see #MINOR_11
* */
public static final short MAJOR_11 = 55;
/** Minor version number of class files for Java 11.
* @see #MAJOR_11
* */
public static final short MINOR_1_9 = 0;
public static final short MINOR_11 = 0;
/** Major version number of class files for Java 12.
* @see #MINOR_12
* */
public static final short MAJOR_12 = 56;
/** Minor version number of class files for Java 12.
* @see #MAJOR_12
* */
public static final short MINOR_12 = 0;
/** Major version number of class files for Java 13.
* @see #MINOR_13
* */
public static final short MAJOR_13 = 57;
/** Minor version number of class files for Java 13.
* @see #MAJOR_13
* */
public static final short MINOR_13 = 0;
/** Default major version number. Class file is for Java 1.1.
* @see #MAJOR_1_1
......@@ -364,6 +416,14 @@ public final class Const {
*/
public static final byte CONSTANT_MethodType = 16;
/**
* Marks a constant pool entry as dynamically computed.
* @see <a href="https://bugs.openjdk.java.net/secure/attachment/74618/constant-dynamic.html">
* Change request for JEP 309</a>
* @since 6.3
*/
public static final byte CONSTANT_Dynamic = 17;
/**
* Marks a constant pool entry as an Invoke Dynamic
* @see <a href="http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.10">
......@@ -373,22 +433,16 @@ public final class Const {
/**
* Marks a constant pool entry as a Module Reference.
*
* <p>Note: Early access Java 9 support- currently subject to change</p>
*
* @see <a href="http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html#jigsaw-2.6">
* JPMS: Modules in the Java Language and JVM</a>
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.11">
* The Constant Pool in The Java Virtual Machine Specification</a>
* @since 6.1
*/
public static final byte CONSTANT_Module = 19;
/**
* Marks a constant pool entry as a Package Reference.
*
* <p>Note: Early access Java 9 support- currently subject to change</p>
*
* @see <a href="http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html#jigsaw-2.6">
* JPMS: Modules in the Java Language and JVM</a>
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4.12">
* The Constant Pool in The Java Virtual Machine Specification</a>
* @since 6.1
*/
public static final byte CONSTANT_Package = 20;
......@@ -403,7 +457,7 @@ public final class Const {
"CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
"CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
"CONSTANT_NameAndType", "", "", "CONSTANT_MethodHandle",
"CONSTANT_MethodType", "", "CONSTANT_InvokeDynamic",
"CONSTANT_MethodType", "CONSTANT_Dynamic", "CONSTANT_InvokeDynamic",
"CONSTANT_Module", "CONSTANT_Package"};
/**
......
......@@ -127,52 +127,54 @@ public abstract class Constant implements Cloneable, Node {
/**
* Read one constant from the given input, the type depends on a tag byte.
*
* @param input Input stream
* @param dataInput Input stream
* @return Constant object
* @throws IOException if an I/O error occurs reading from the given {@code dataInput}.
* @throws ClassFormatException if the next byte is not recognized
* @since 6.0 made public
*/
public static Constant readConstant( final DataInput input ) throws IOException,
ClassFormatException {
final byte b = input.readByte(); // Read tag byte
public static Constant readConstant(final DataInput dataInput) throws IOException, ClassFormatException {
final byte b = dataInput.readByte(); // Read tag byte
switch (b) {
case Const.CONSTANT_Class:
return new ConstantClass(input);
case Const.CONSTANT_Fieldref:
return new ConstantFieldref(input);
case Const.CONSTANT_Methodref:
return new ConstantMethodref(input);
case Const.CONSTANT_InterfaceMethodref:
return new ConstantInterfaceMethodref(input);
case Const.CONSTANT_String:
return new ConstantString(input);
case Const.CONSTANT_Integer:
return new ConstantInteger(input);
case Const.CONSTANT_Float:
return new ConstantFloat(input);
case Const.CONSTANT_Long:
return new ConstantLong(input);
case Const.CONSTANT_Double:
return new ConstantDouble(input);
case Const.CONSTANT_NameAndType:
return new ConstantNameAndType(input);
case Const.CONSTANT_Utf8:
return ConstantUtf8.getInstance(input);
case Const.CONSTANT_MethodHandle:
return new ConstantMethodHandle(input);
case Const.CONSTANT_MethodType:
return new ConstantMethodType(input);
case Const.CONSTANT_InvokeDynamic:
return new ConstantInvokeDynamic(input);
case Const.CONSTANT_Module:
return new ConstantModule(input);
case Const.CONSTANT_Package:
return new ConstantPackage(input);
default:
throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
case Const.CONSTANT_Class:
return new ConstantClass(dataInput);
case Const.CONSTANT_Fieldref:
return new ConstantFieldref(dataInput);
case Const.CONSTANT_Methodref:
return new ConstantMethodref(dataInput);
case Const.CONSTANT_InterfaceMethodref:
return new ConstantInterfaceMethodref(dataInput);
case Const.CONSTANT_String:
return new ConstantString(dataInput);
case Const.CONSTANT_Integer:
return new ConstantInteger(dataInput);
case Const.CONSTANT_Float:
return new ConstantFloat(dataInput);
case Const.CONSTANT_Long:
return new ConstantLong(dataInput);
case Const.CONSTANT_Double:
return new ConstantDouble(dataInput);
case Const.CONSTANT_NameAndType:
return new ConstantNameAndType(dataInput);
case Const.CONSTANT_Utf8:
return ConstantUtf8.getInstance(dataInput);
case Const.CONSTANT_MethodHandle:
return new ConstantMethodHandle(dataInput);
case Const.CONSTANT_MethodType:
return new ConstantMethodType(dataInput);
case Const.CONSTANT_Dynamic:
return new ConstantDynamic(dataInput);
case Const.CONSTANT_InvokeDynamic:
return new ConstantInvokeDynamic(dataInput);
case Const.CONSTANT_Module:
return new ConstantModule(dataInput);
case Const.CONSTANT_Package:
return new ConstantPackage(dataInput);
default:
throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
}
}
/**
* @return Comparison strategy object
*/
......
......@@ -27,7 +27,6 @@ import org.apache.bcel.Const;
* This class is derived from the abstract {@link Constant}
* and represents a reference to a (external) class.
*
* @version $Id$
* @see Constant
*/
public final class ConstantClass extends Constant implements ConstantObject {
......@@ -44,13 +43,13 @@ public final class ConstantClass extends Constant implements ConstantObject {
/**
* Initialize instance from file data.
* Constructs an instance from file data.
*
* @param file Input stream
* @throws IOException
* @param dataInput Input stream
* @throws IOException if an I/O error occurs reading from the given {@code dataInput}.
*/
ConstantClass(final DataInput file) throws IOException {
this(file.readUnsignedShort());
ConstantClass(final DataInput dataInput) throws IOException {
this(dataInput.readUnsignedShort());
}
......@@ -78,10 +77,10 @@ public final class ConstantClass extends Constant implements ConstantObject {
/**
* Dump constant class to file stream in binary format.
* Dumps constant class to file stream in binary format.
*
* @param file Output file stream
* @throws IOException
* @throws IOException if an I/O error occurs writing to the DataOutputStream.
*/
@Override
public final void dump( final DataOutputStream file ) throws IOException {
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.bcel.classfile;
import java.io.DataInput;
import java.io.IOException;
import org.apache.bcel.Const;
/**
* This class is derived from the abstract {@link Constant}
* and represents a reference to a dynamically computed constant.
*
* @see Constant
* @see <a href="https://bugs.openjdk.java.net/secure/attachment/74618/constant-dynamic.html">
* Change request for JEP 309</a>
* @since 6.3
*/
public final class ConstantDynamic extends ConstantCP {
/**
* Initialize from another object.
*/
public ConstantDynamic(final ConstantDynamic c) {
this(c.getBootstrapMethodAttrIndex(), c.getNameAndTypeIndex());
}
/**
* Initialize instance from file data.
*
* @param file Input stream
* @throws IOException
*/
ConstantDynamic(final DataInput file) throws IOException {
this(file.readShort(), file.readShort());
}
public ConstantDynamic(final int bootstrap_method_attr_index, final int name_and_type_index) {
super(Const.CONSTANT_Dynamic, bootstrap_method_attr_index, name_and_type_index);
}
/**
* Called by objects that are traversing the nodes of the tree implicitly
* defined by the contents of a Java class. I.e., the hierarchy of methods,
* fields, attributes, etc. spawns a tree of objects.
*
* @param v Visitor object
*/
@Override
public void accept( final Visitor v ) {
v.visitConstantDynamic(this);
}
/**
* @return Reference (index) to bootstrap method this constant refers to.
*
* Note that this method is a functional duplicate of getClassIndex
* for use by ConstantInvokeDynamic.
* @since 6.0
*/
public final int getBootstrapMethodAttrIndex() {
return super.getClassIndex(); // AKA bootstrap_method_attr_index
}
/**
* @return String representation
*/
@Override
public final String toString() {
return super.toString().replace("class_index", "bootstrap_method_attr_index");
}
}
......@@ -543,4 +543,12 @@ public class DescendingVisitor implements Visitor
obj.accept(visitor);
stack.pop();
}
/** @since 6.3 */
@Override
public void visitConstantDynamic(final ConstantDynamic obj) {
stack.push(obj);
obj.accept(visitor);
stack.pop();
}
}
......@@ -310,4 +310,12 @@ public class EmptyVisitor implements Visitor
@Override
public void visitConstantModule(final ConstantModule constantModule) {
}
/**
* @since 6.3
*/
@Override
public void visitConstantDynamic(final ConstantDynamic obj) {
}
}
......@@ -156,4 +156,11 @@ public interface Visitor
* @since 6.1
*/
void visitConstantModule(ConstantModule constantModule);
/**
* @since 6.3
*/
default void visitConstantDynamic(ConstantDynamic constantDynamic) {
// empty
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.bcel.util;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Wraps a Java 9 JEP 220 modular runtime image. Requires the JRT NIO file system.
*
* @since 6.3
*/
public class ModularRuntimeImage implements Closeable {
static final String MODULES_PATH = File.separator + "modules";
static final String PACKAGES_PATH = File.separator + "packages";
private final URLClassLoader classLoader;
private final FileSystem fileSystem;
/**
* Constructs a default instance.
*
* @throws IOException
* an I/O error occurs accessing the file system
*/
public ModularRuntimeImage() throws IOException {
this(null, FileSystems.getFileSystem(URI.create("jrt:/")));
}
/**
* Constructs an instance using the JRT file system implementation from a specific Java Home.
*
* @param javaHome
* Path to a Java 9 or greater home.
*
* @throws IOException
* an I/O error occurs accessing the file system
*/
public ModularRuntimeImage(final String javaHome) throws IOException {
final Map<String, ?> emptyMap = Collections.emptyMap();
final Path jrePath = Paths.get(javaHome);
final Path jrtFsPath = jrePath.resolve("lib").resolve("jrt-fs.jar");
this.classLoader = new URLClassLoader(new URL[] {jrtFsPath.toUri().toURL() });
this.fileSystem = FileSystems.newFileSystem(URI.create("jrt:/"), emptyMap, classLoader);
}
private ModularRuntimeImage(final URLClassLoader cl, final FileSystem fs) {
this.classLoader = cl;
this.fileSystem = fs;
}
@Override
public void close() throws IOException {
if (classLoader != null) {
if (classLoader != null) {
classLoader.close();
}
if (fileSystem != null) {
fileSystem.close();
}
}
}
/**
* Lists all entries in the given directory.
*
* @param dirPath
* directory path.
* @return a list of dir entries if an I/O error occurs
* @throws IOException
* an I/O error occurs accessing the file system
*/
public List<Path> list(final Path dirPath) throws IOException {
final List<Path> list = new ArrayList<>();
try (DirectoryStream<Path> ds = Files.newDirectoryStream(dirPath)) {
final Iterator<Path> iterator = ds.iterator();
while (iterator.hasNext()) {
list.add(iterator.next());
}
}
return list;
}
/**
* Lists all entries in the given directory.
*
* @param dirName
* directory path.
* @return a list of dir entries if an I/O error occurs
* @throws IOException
* an I/O error occurs accessing the file system
*/
public List<Path> list(final String dirName) throws IOException {
return list(fileSystem.getPath(dirName));
}
/**
* Lists all modules.
*
* @return a list of modules
* @throws IOException
* an I/O error occurs accessing the file system
*/
public List<Path> modules() throws IOException {
return list(MODULES_PATH);
}
/**
* Lists all packages.
*
* @return a list of modules
* @throws IOException
* an I/O error occurs accessing the file system
*/
public List<Path> packages() throws IOException {
return list(PACKAGES_PATH);
}
public FileSystem getFileSystem() {
return fileSystem;
}
}
......@@ -30,43 +30,45 @@ import org.apache.bcel.classfile.JavaClass;
public interface Repository {
/**
* Store the provided class under "clazz.getClassName()"
* Stores the provided class under "clazz.getClassName()"
*/
void storeClass( JavaClass clazz );
/**
* Remove class from repository
* Removes class from repository
*/
void removeClass( JavaClass clazz );
/**
* Find the class with the name provided, if the class
* Finds the class with the name provided, if the class
* isn't there, return NULL.
*/
JavaClass findClass( String className );
/**
* Find the class with the name provided, if the class
* Finds the class with the name provided, if the class
* isn't there, make an attempt to load it.
*/
JavaClass loadClass( String className ) throws java.lang.ClassNotFoundException;
/**
* Find the JavaClass instance for the given run-time class object
* Finds the JavaClass instance for the given run-time class object
*/
JavaClass loadClass( Class<?> clazz ) throws java.lang.ClassNotFoundException;
/** Clear all entries from cache.
/**
* Clears all entries from cache.
*/
void clear();
/** Get the ClassPath associated with this Repository
/**
* Gets the ClassPath associated with this Repository
*/
ClassPath getClassPath();
}