This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push:
new d7292a3 [BCEL-315] NullPointerException at
org.apache.bcel.classfile.FieldOrMethod.dump().
d7292a3 is described below
commit d7292a3d9f2939f785ec74057d255e5df95846bf
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Mar 20 17:15:14 2019 -0400
[BCEL-315] NullPointerException at
org.apache.bcel.classfile.FieldOrMethod.dump().
---
src/changes/changes.xml | 893 +++++++++++----------
.../org/apache/bcel/classfile/FieldOrMethod.java | 588 +++++++-------
2 files changed, 742 insertions(+), 739 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6a5c7d1..1faa3a7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -1,446 +1,447 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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 also used by the maven-changes-plugin to generate the release
notes.
-Useful ways of finding items to add to this file are:
-
-1. Add items when you fix a bug or add a feature (this makes the
-release process easy :-).
-
-2. Do a JIRA search for tickets closed since the previous release.
-
-3. Use the report generated by the maven-changelog-plugin to see all
-SVN commits. TBA how to use this with SVN.
-
-To generate the release notes from this file:
-
-mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
-
-then tweak the formatting if necessary
-and commit
-
-The <action> type attribute can be add,update,fix,remove.
--->
-
-<document>
- <properties>
- <title>Changes</title>
- <author email="[email protected]">Apache Commons developers</author>
- </properties>
-
- <!-- NOTE:
- The description below is specially formatted so as to improve the layout of
the generated release notes:
- The parsing process removes all line feeds, replacing them with a single
space.
- The Velocity template in resources/templates has been enhanced to replace
pairs of adjacent spaces
- with a new-line in the release notes. (These spaces are ignored when
displaying HTML).
- If the output is not quite correct, check for invisible trailing spaces!
-
- N.B. The release notes template groups actions by type, and only extracts
data for the current release.
- The changes report outputs actions in the order they appear in this file.
-
- To regenerate the release notes:
- mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
-
- Defining changes.version allows one to create the RN without first removing
the SNAPSHOT suffix.
- -->
-
- <body>
- <release version="6.4" date="2019-MM-DD" description="TO DO">
- <action issue="BCEL-267" type="fix" dev="ggregory" due-to="Stephan
Herrmann, Sebb, Gary Gregory, Torsten Curdt">Race conditions on static fields
in BranchHandle and InstructionHandle.</action>
- <action issue="BCEL-297" type="fix" dev="ggregory" due-to="Mark Roberts,
mingleizhang">Possible NPE in override implementation of Object.equals
(#20)</action>
- <action issue="BCEL-298" type="update" dev="ggregory"
due-to="mingleizhang">Add some files to .gitignore (#19)</action>
- </release>
-
- <release version="6.3" date="2019-01-23" 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>
- <action issue="BCEL-300" type="fix"
dev="ggregory">org.apache.bcel.classfile.ClassFormatException: Invalid byte tag
in constant pool: 19.</action>
- <action issue="BCEL-301" type="fix"
dev="ggregory">org.apache.bcel.classfile.ClassFormatException: Invalid byte tag
in constant pool: 20.</action>
- </release>
-
- <release version="6.1" date="2017-09-14" description="Experimental Java 9
Support">
- <action issue="BCEL-293" type="add" dev="britter">Add
Automatic-Module-Name MANIFEST entry for Java 9 compatibility</action>
- <action issue="BCEL-292" type="add" dev="markt">Add minimal Java 9
support</action>
- <action issue="BCEL-286" type="fix" dev="britter" due-to="Mark
Roberts">Utility.signatureToString fails if a method has multiple type
arguments</action>
- <action issue="BCEL-287" type="fix" dev="britter" due-to="Mark
Roberts">IINC does not handle -128 properly</action>
- <action issue="BCEL-283" type="fix" dev="britter" due-to="Mark
Roberts">Support for StackMap should be different from StackMapTable</action>
- <action issue="BCEL-289" type="fix" dev="kinow">Crash when parsing
constructor of inner classes with parameters annotated</action>
- <action issue="BCEL-276" type="fix" dev="britter" due-to="Sam Yoon, Mark
Roberts">LocalVariableTypeTable is not updated.</action>
- <action issue="BCEL-277" type="fix" dev="britter" due-to="Sam
Yoon">Resolving the String representation of a constant throws
NoSuchElementException in case of CONSTANT_NameAndType constant.</action>
- </release>
-
- <release version="6.0" date="2016-07-10" description="Apache Commons BCEL
6.0 is a major release supporting the new features
- introduced in Java 6, 7 and 8.
-
-
- It requires Java 7 or higher to run.
-
-
-COMPATIBILITY with 5.2
- ======================
-
-
- Binary compatible - not strictly compatible
- - The constant interface org.apache.bcel.Constants has been deprecated.
Classes
- which implemented this interface in 5.2 now use the constants defined in the
- org.apache.bcel.Const class.
- - The constant interface org.apache.bcel.generic.InstructionConstants has been
- deprecated. Classes which implemented this interface in 5.2 now use the
- constants defined in the org.apache.bcel.generic.InstructionConsts class.
- - Return type of method 'public java.lang.Object getElementAt(int)' in
- org.apache.bcel.verifier.VerifierFactoryListModel has been changed to
- java.lang.String.
- - The BCEL classes do no longer implement java.io.Serializable.
-
-
-
-Source compatible - Yes, sort of;
- - The org.apache.bcel.classfile.Visitor interface has been enhanced with
- additional methods. If you implemented it directly instead of extending
- the EmptyVisitor class you'll have to implement the new methods.
- - The org.apache.bcel.generic.Visitor interface has been enhanced with an
- additional method. If you implemented it directly instead of extending
- the EmptyVisitor class you'll have to implement the new methods.
-
-
- Semantic compatible - Yes, except:
- - BCEL 6.0 handles new attributes such as code annotations that could only
- be processed by implementing a custom AttributeReader in the previous
- versions. Code relying on this behavior will have to be adjusted since
- the AttributeReader will no longer be called in these cases.
-
-
-
-For full information about API changes please see the extended Clirr report:
-
- http://commons.apache.org/bcel/clirr-report.html">
- <action issue="BCEL-262" type="update" dev="britter" due-to="Mark
Roberts">InvokeInstruction.getClassName(ConstantPoolGen)
- should not throw an exception when
it detects an array.</action>
- <action issue="BCEL-237" type="fix" dev="sebb">non-empty final arrays
should be private as they are mutable.</action>
- <action issue="BCEL-230" type="update" dev="britter">Document the Java
platform requirement clearly and early.</action>
- <action issue="BCEL-243" type="fix">Type.getType() needs to understand
TypeVariableSignature(s).</action>
- <action issue="BCEL-272" type="add">Add constants for Java 9 class file
version 53.</action>
- <action issue="BCEL-271" type="fix">FCONST pattern does not include
FCONST_2.</action>
- <action issue="BCEL-264" type="fix">Add missing Node.accept()
implementations (ConstantMethodHandle,
- ConstantMethodType,
ParameterAnnotationEntry).</action>
- <action issue="BCEL-221" type="fix">BCELifier is not working for
Java8Example (incomplete).</action>
- <action issue="BCEL-195" type="fix">Addition of hashCode() to
generic/Instruction.java breaks Targeters.
- Never make distinct
BranchInstructions compare equal.</action>
- <action issue="BCEL-261" type="fix">Select constructor allows partially
constructed instance to escape.
- Re-ordered code to delay the
escape.</action>
- <action issue="BCEL-259" type="fix">Minor doc error in
BranchInstruction.java.</action>
- <action issue="BCEL-260" type="fix">ClassDumper example duplicates field
attribute types.</action>
- <action issue="BCEL-258" type="fix">No tests to check the output of dump
methods.</action>
- <action issue="BCEL-257" type="fix">INVOKESPECIAL, INVOKESTATIC,
INVOKEVIRTUAL need to define dump()
- methods.</action>
- <action issue="BCEL-254" type="fix">Two more methods that would be nice
to be public.</action>
- <action issue="BCEL-245" type="fix">Type class includes constants that
reference subclasses.</action>
- <action issue="BCEL-253" type="fix">Pass 3b verifier is too
strict.</action>
- <action issue="BCEL-248" type="fix">StackMapTable[Entry] should be
removed and improvements merged into
- StackMap[Entry].</action>
- <action issue="BCEL-202" type="fix">StackMap[Table]Entry.copy() needs to
be deep; Improved support for
- StackMaps.</action>
- <action issue="BCEL-251" type="fix">Pass3aVerifier visitANEWARRAY() does
not allow 255 array dimensions.</action>
- <action issue="BCEL-211" type="update">Some additional clone methods
should be public.</action>
- <action issue="BCEL-249" type="fix">Check for max Short seems
wrong.</action>
- <action issue="BCEL-127" type="update">Document that Instruction Factory
returns singleton instances.</action>
- <action issue="BCEL-198" type="update">better support for clone/copy
methods.</action>
- <action issue="BCEL-242" type="remove">Remove Serializable.</action>
- <action issue="BCEL-110" type="remove">Problem with JAXB if the bcel
classloader is used; remove the broken
- ClassLoader class.</action>
- <action issue="BCEL-201" type="update">modify several toString methods
to make output similar to "javap".</action>
- <action issue="BCEL-205" type="update">add javadoc comments to
LineNumber.java and LineNumberTable.java.</action>
- <action issue="BCEL-208" type="fix">Need to check for an empty
InstructionList.</action>
- <action issue="BCEL-212" type="update">Inconsistent toString()
results.</action>
- <action issue="BCEL-217" type="fix">long type instructions are not
searched by InstructionFinder using
- regular expression.</action>
- <action issue="BCEL-244" type="update" dev="ggregory">Update Java
requirement from 5 to 7.</action>
- <action issue="BCEL-239" type="fix">Interfaces should not be used to
define constants.</action>
- <action issue="BCEL-234" type="fix">Code must not swallow
Throwable.</action>
- <action issue="BCEL-219" type="update" due-to="Maxim Degtyarev">
- Make org.apache.bcel.classfile.ConstantPool.ConstantPool(DataInput)
- public.
- </action>
- <action issue="BCEL-209" type="fix" due-to="Mark Roberts">
- Bug fixes and improvements to InvokeDynamic and BootStrapMethods
- implementation.
- </action>
- <action issue="BCEL-187" type="fix" due-to="Jérôme Leroux">
- Verification error when an invoke references a method defined in
- superclass.
- </action>
- <action issue="BCEL-218" type="fix" due-to="chas">
- Remove ObjectType cache.
- </action>
- <action issue="BCEL-184" type="fix" due-to="Jérôme Leroux">
- The verifier now checks if methods with a void return type attempt
- to return an object.
- </action>
- <action issue="BCEL-207" type="fix" due-to="Mark Roberts">
- MethodGen.removeLocalVariable now properly unreference the removed
- variable from the targetters of the instruction handlers delimiting
- the scope of the variable.
- </action>
- <action issue="BCEL-197" type="fix" due-to="Mark Roberts">
- Utility.signatureToString() no longer throws a ClassFormatException
- on TypeVariables found in generic signatures.
- </action>
- <action issue="BCEL-194" type="fix" due-to="Mark Roberts">
- Removed the 'index' variable from the LocalVariableGen's hash code.
- </action>
- <action issue="BCEL-193" type="fix" dev="markt" due-to="Jérôme Leroux">
- The verifier should not check for run time compatibility of objects
- assigned to arrays.
- </action>
- <action issue="BCEL-188" type="fix" dev="markt" due-to="Jérôme Leroux">
- Correct verification of the return value of a method.
- </action>
- <action issue="BCEL-186" type="fix" dev="sebb">
- Performance degradation with the UTF8 cache. getInstance no longer
- uses cache.
- </action>
- <action issue="BCEL-181" type="fix" dev="ggregory">
- org.apache.bcel.util.ClassLoaderRepository.loadClass(String) leaks
- input streams.
- </action>
- <action issue="BCEL-76" type="update">
- Add parent type processing for ClassPath class.
- </action>
- <action issue="BCEL-83" type="update">
- Add support for getResource and getResourceAsStream to ClassPath.
- </action>
- <action issue="BCEL-92" type="update">
- Properly parse StackMapTable attributes in Java 6 classfiles.
- </action>
- <action issue="BCEL-104" type="update">
- Javadoc overhaul.
- </action>
- <action issue="BCEL-119" type="update">
- BCEL is unnecessarily slow.
- </action>
- <action issue="BCEL-157" type="update">
- Add support for INVOKEDYNAMIC and MethodHandles.
- </action>
- <action issue="BCEL-160" type="update" dev="sebb">
- Why using unstable sort at MethodGen.getLocalVariables() ?
- </action>
- <action issue="BCEL-163" type="update">
- Incorporate patch file from Findbugs.
- </action>
- <action issue="BCEL-175" type="update">
- Implement the MethodParameters attribute.
- </action>
- <action issue="BCEL-28" type="fix">
- Mistake in "Peephole optimizer" example
- at http://commons.apache.org/bcel/manual.html
- </action>
- <action issue="BCEL-74" type="fix">
- BCEL cannot be used as java.system.class.loader.
- </action>
- <action issue="BCEL-77" type="fix">
- XSLT transforms broken in Turkish Locale.
- </action>
- <action issue="BCEL-79" type="fix">
- java.lang.ClassFormatError: LVTT entry for 'local' in class file
- org/shiftone/jrat/test/dummy/CrashTestDummy does not match any LVT
- entry
- </action>
- <action issue="BCEL-81" type="fix">
- ClassParser.parse() throws NullPointerException if class does not
- exist and ClassParser(String) constructor is used.
- </action>
- <action issue="BCEL-85" type="fix">
- ArrayOutOfBoundsException in InstructionFinder.
- </action>
- <action issue="BCEL-87" type="fix">
- Website: Incorrect URL for source; version 5.2 is not in the bug
- page
- </action>
- <action issue="BCEL-88" type="fix">
- bcelified method doesn't pass verification.
- </action>
- <action issue="BCEL-89" type="fix">
- return type not verified by JustIce.
- </action>
- <action issue="BCEL-94" type="fix">
- @since tag incorrect for Annotation classes in BCEL trunk.
- </action>
- <action issue="BCEL-95" type="fix">
- InstructionFactory missing % operator for Float, Double.
- </action>
- <action issue="BCEL-96" type="fix">
- Fields in Annotations and AnnotationEntry are inaccessible to
- subclasses
- </action>
- <action issue="BCEL-97" type="fix">
- Add support for getResources to ClassPath.
- </action>
- <action issue="BCEL-98" type="fix">
- Two source files in repository are empty.
- </action>
- <action issue="BCEL-99" type="fix">
- Maven POM file calls in apache regex but code does not use it.
- </action>
- <action issue="BCEL-100" type="fix">
- ClassParser throws unintelligible Exception.
- </action>
- <action issue="BCEL-101" type="fix">
- verifier raises an AssertionViolatedException when done against
- Java 5 files with generics/annotations.
- </action>
- <action issue="BCEL-102" type="fix">
- Verifier fails in pass 2 with "Number of LocalVariableTable
- attributes of Code attribute" on static methods.
- </action>
- <action issue="BCEL-107" type="fix">
- ParameterAnnotationEntries are read not dumped.
- </action>
- <action issue="BCEL-108" type="fix">
- RuntimeVisible Annotations duplicated.
- </action>
- <action issue="BCEL-112" type="fix">
- ARRAYLENGTH incorrectly not StackConsumer.
- </action>
- <action issue="BCEL-114" type="fix">
- Error in method search() defined in
- org.apache.bcel.util.InstructionFinder
- </action>
- <action issue="BCEL-115" type="fix">
- Deleting all instructions of a list shows wrong behaviour.
- </action>
- <action issue="BCEL-120" type="fix">
- Make BCEL JAR OSGi compatible.
- </action>
- <action issue="BCEL-122" type="fix">
- ArrayIndexOutOfBoundsException thrown from TABLESWITCH.initFromFile.
- </action>
- <action issue="BCEL-124" type="fix">
- tableswitch/lookupswitch invalid alignment of 4-byte operands.
- </action>
- <action issue="BCEL-125" type="fix">
- Incorrect size calculation in InstructionFinder.
- </action>
- <action issue="BCEL-130" type="fix">
- Class files containing "ParameterAnnotations" are dumped
- incorrectly.
- </action>
- <action issue="BCEL-131" type="fix">
- Class files containing "StackMapTable" attributes (on method code)
- are dumped incorrectly.
- </action>
- <action issue="BCEL-132" type="fix">
- org.apache.bcel.classfile.ClassParser: NullPointerException caused
- by fileopen failed.
- </action>
- <action issue="BCEL-133" type="fix">
- org.apache.bcel.classfile.ClassParser: NullPointerException caused
- by invalid filename.
- </action>
- <action issue="BCEL-134" type="fix">
- ExecutionVisitor doesn't support Class constant type for LDC and
- LDC_W.
- </action>
- <action issue="BCEL-135" type="fix">
- BCELifier issue: BCELFactory fails to handle float and long
- constants.
- </action>
- <action issue="BCEL-137" type="fix">
- "Invalid method signature: TT;" when using MethodGen for a method
- having a generic parameter.
- </action>
- <action issue="BCEL-138" type="fix">
- FieldInstruction.getFieldSize() doesn't decode Type.getTypeSize()
- output.
- </action>
- <action issue="BCEL-140" type="fix">
- org.apache.bcel.generic.Instruction.equals(Object) does not follow
- Object.equals(Object) rules.
- </action>
- <action issue="BCEL-141" type="fix">
- Select instructions should implement StackConsumer instead of
- StackProducer.
- </action>
- <action issue="BCEL-143" type="fix">
- Fix CPL License issues with EnclosingMethod.java and
- LocalVariableTypeTable.java.
- </action>
- <action issue="BCEL-145" type="fix">
- Type.getReturnTypeSize() doesn't decode Type.getTypeSize() output.
- </action>
- <action issue="BCEL-146" type="fix">
- SyntheticRepository.loadClass() fails to close the inputStream.
- </action>
- <action issue="BCEL-148" type="fix">
- BCELifier produces incorrect code for methods containing loads of
- class literals from constant pool.
- </action>
- <action issue="BCEL-151" type="fix">
- Code attribute size not updated.
- </action>
- <action issue="BCEL-152" type="fix">
- Incorrect link for Jasmin assembler language.
- </action>
- <action issue="BCEL-153" type="fix" dev="sebb">
- Examples not present in source or binary downloads.
- </action>
- <action issue="BCEL-154" type="fix">
- ClassParser.parse() generates NPE if it cannot open the file.
- </action>
- <action issue="BCEL-155" type="fix">
- InstConstraintVisitor does not handle class constants.
- </action>
- <action issue="BCEL-156" type="fix">
- Pass3bVerifier crashes on empty methods.
- </action>
- <action issue="BCEL-159" type="fix">
- LocalVariableGen.getLocalVariable() computes incorrect length.
- </action>
- <action issue="BCEL-164" type="fix">
- Method does not have a method to access parameter annotations.
- </action>
- <action issue="BCEL-167" type="fix">
- ClassPath.getResource does not correctly perform URL escaping.
- </action>
- <action issue="BCEL-173" type="fix">
- ClassParser fails to parse JDK classes in Java 8:
- ClassFormatException: Invalid byte tag in constant pool.
- </action>
- <action issue="BCEL-174" type="fix">
- Verification of interfaces with default methods fails with Java 8.
- </action>
- <action issue="BCEL-177" type="fix" dev="markt">
- When reading the number of parameters in a MethodParameters
- structure only read a single byte as per the JVM specification.
- </action>
- </release>
- </body>
-</document>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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 also used by the maven-changes-plugin to generate the release
notes.
+Useful ways of finding items to add to this file are:
+
+1. Add items when you fix a bug or add a feature (this makes the
+release process easy :-).
+
+2. Do a JIRA search for tickets closed since the previous release.
+
+3. Use the report generated by the maven-changelog-plugin to see all
+SVN commits. TBA how to use this with SVN.
+
+To generate the release notes from this file:
+
+mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
+
+then tweak the formatting if necessary
+and commit
+
+The <action> type attribute can be add,update,fix,remove.
+-->
+
+<document>
+ <properties>
+ <title>Changes</title>
+ <author email="[email protected]">Apache Commons developers</author>
+ </properties>
+
+ <!-- NOTE:
+ The description below is specially formatted so as to improve the layout of
the generated release notes:
+ The parsing process removes all line feeds, replacing them with a single
space.
+ The Velocity template in resources/templates has been enhanced to replace
pairs of adjacent spaces
+ with a new-line in the release notes. (These spaces are ignored when
displaying HTML).
+ If the output is not quite correct, check for invisible trailing spaces!
+
+ N.B. The release notes template groups actions by type, and only extracts
data for the current release.
+ The changes report outputs actions in the order they appear in this file.
+
+ To regenerate the release notes:
+ mvn changes:announcement-generate -Prelease-notes [-Dchanges.version=nnn]
+
+ Defining changes.version allows one to create the RN without first removing
the SNAPSHOT suffix.
+ -->
+
+ <body>
+ <release version="6.4" date="2019-MM-DD" description="TO DO">
+ <action issue="BCEL-267" type="fix" dev="ggregory" due-to="Stephan
Herrmann, Sebb, Gary Gregory, Torsten Curdt">Race conditions on static fields
in BranchHandle and InstructionHandle.</action>
+ <action issue="BCEL-297" type="fix" dev="ggregory" due-to="Mark Roberts,
mingleizhang">Possible NPE in override implementation of Object.equals
(#20)</action>
+ <action issue="BCEL-298" type="update" dev="ggregory"
due-to="mingleizhang">Add some files to .gitignore (#19)</action>
+ <action issue="BCEL-315" type="fix" dev="ggregory" due-to="Gary
Gregory">NullPointerException at
org.apache.bcel.classfile.FieldOrMethod.dump().</action>
+ </release>
+
+ <release version="6.3" date="2019-01-23" 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>
+ <action issue="BCEL-300" type="fix"
dev="ggregory">org.apache.bcel.classfile.ClassFormatException: Invalid byte tag
in constant pool: 19.</action>
+ <action issue="BCEL-301" type="fix"
dev="ggregory">org.apache.bcel.classfile.ClassFormatException: Invalid byte tag
in constant pool: 20.</action>
+ </release>
+
+ <release version="6.1" date="2017-09-14" description="Experimental Java 9
Support">
+ <action issue="BCEL-293" type="add" dev="britter">Add
Automatic-Module-Name MANIFEST entry for Java 9 compatibility</action>
+ <action issue="BCEL-292" type="add" dev="markt">Add minimal Java 9
support</action>
+ <action issue="BCEL-286" type="fix" dev="britter" due-to="Mark
Roberts">Utility.signatureToString fails if a method has multiple type
arguments</action>
+ <action issue="BCEL-287" type="fix" dev="britter" due-to="Mark
Roberts">IINC does not handle -128 properly</action>
+ <action issue="BCEL-283" type="fix" dev="britter" due-to="Mark
Roberts">Support for StackMap should be different from StackMapTable</action>
+ <action issue="BCEL-289" type="fix" dev="kinow">Crash when parsing
constructor of inner classes with parameters annotated</action>
+ <action issue="BCEL-276" type="fix" dev="britter" due-to="Sam Yoon, Mark
Roberts">LocalVariableTypeTable is not updated.</action>
+ <action issue="BCEL-277" type="fix" dev="britter" due-to="Sam
Yoon">Resolving the String representation of a constant throws
NoSuchElementException in case of CONSTANT_NameAndType constant.</action>
+ </release>
+
+ <release version="6.0" date="2016-07-10" description="Apache Commons BCEL
6.0 is a major release supporting the new features
+ introduced in Java 6, 7 and 8.
+
+
+ It requires Java 7 or higher to run.
+
+
+COMPATIBILITY with 5.2
+ ======================
+
+
+ Binary compatible - not strictly compatible
+ - The constant interface org.apache.bcel.Constants has been deprecated.
Classes
+ which implemented this interface in 5.2 now use the constants defined in the
+ org.apache.bcel.Const class.
+ - The constant interface org.apache.bcel.generic.InstructionConstants has been
+ deprecated. Classes which implemented this interface in 5.2 now use the
+ constants defined in the org.apache.bcel.generic.InstructionConsts class.
+ - Return type of method 'public java.lang.Object getElementAt(int)' in
+ org.apache.bcel.verifier.VerifierFactoryListModel has been changed to
+ java.lang.String.
+ - The BCEL classes do no longer implement java.io.Serializable.
+
+
+
+Source compatible - Yes, sort of;
+ - The org.apache.bcel.classfile.Visitor interface has been enhanced with
+ additional methods. If you implemented it directly instead of extending
+ the EmptyVisitor class you'll have to implement the new methods.
+ - The org.apache.bcel.generic.Visitor interface has been enhanced with an
+ additional method. If you implemented it directly instead of extending
+ the EmptyVisitor class you'll have to implement the new methods.
+
+
+ Semantic compatible - Yes, except:
+ - BCEL 6.0 handles new attributes such as code annotations that could only
+ be processed by implementing a custom AttributeReader in the previous
+ versions. Code relying on this behavior will have to be adjusted since
+ the AttributeReader will no longer be called in these cases.
+
+
+
+For full information about API changes please see the extended Clirr report:
+
+ http://commons.apache.org/bcel/clirr-report.html">
+ <action issue="BCEL-262" type="update" dev="britter" due-to="Mark
Roberts">InvokeInstruction.getClassName(ConstantPoolGen)
+ should not throw an exception when
it detects an array.</action>
+ <action issue="BCEL-237" type="fix" dev="sebb">non-empty final arrays
should be private as they are mutable.</action>
+ <action issue="BCEL-230" type="update" dev="britter">Document the Java
platform requirement clearly and early.</action>
+ <action issue="BCEL-243" type="fix">Type.getType() needs to understand
TypeVariableSignature(s).</action>
+ <action issue="BCEL-272" type="add">Add constants for Java 9 class file
version 53.</action>
+ <action issue="BCEL-271" type="fix">FCONST pattern does not include
FCONST_2.</action>
+ <action issue="BCEL-264" type="fix">Add missing Node.accept()
implementations (ConstantMethodHandle,
+ ConstantMethodType,
ParameterAnnotationEntry).</action>
+ <action issue="BCEL-221" type="fix">BCELifier is not working for
Java8Example (incomplete).</action>
+ <action issue="BCEL-195" type="fix">Addition of hashCode() to
generic/Instruction.java breaks Targeters.
+ Never make distinct
BranchInstructions compare equal.</action>
+ <action issue="BCEL-261" type="fix">Select constructor allows partially
constructed instance to escape.
+ Re-ordered code to delay the
escape.</action>
+ <action issue="BCEL-259" type="fix">Minor doc error in
BranchInstruction.java.</action>
+ <action issue="BCEL-260" type="fix">ClassDumper example duplicates field
attribute types.</action>
+ <action issue="BCEL-258" type="fix">No tests to check the output of dump
methods.</action>
+ <action issue="BCEL-257" type="fix">INVOKESPECIAL, INVOKESTATIC,
INVOKEVIRTUAL need to define dump()
+ methods.</action>
+ <action issue="BCEL-254" type="fix">Two more methods that would be nice
to be public.</action>
+ <action issue="BCEL-245" type="fix">Type class includes constants that
reference subclasses.</action>
+ <action issue="BCEL-253" type="fix">Pass 3b verifier is too
strict.</action>
+ <action issue="BCEL-248" type="fix">StackMapTable[Entry] should be
removed and improvements merged into
+ StackMap[Entry].</action>
+ <action issue="BCEL-202" type="fix">StackMap[Table]Entry.copy() needs to
be deep; Improved support for
+ StackMaps.</action>
+ <action issue="BCEL-251" type="fix">Pass3aVerifier visitANEWARRAY() does
not allow 255 array dimensions.</action>
+ <action issue="BCEL-211" type="update">Some additional clone methods
should be public.</action>
+ <action issue="BCEL-249" type="fix">Check for max Short seems
wrong.</action>
+ <action issue="BCEL-127" type="update">Document that Instruction Factory
returns singleton instances.</action>
+ <action issue="BCEL-198" type="update">better support for clone/copy
methods.</action>
+ <action issue="BCEL-242" type="remove">Remove Serializable.</action>
+ <action issue="BCEL-110" type="remove">Problem with JAXB if the bcel
classloader is used; remove the broken
+ ClassLoader class.</action>
+ <action issue="BCEL-201" type="update">modify several toString methods
to make output similar to "javap".</action>
+ <action issue="BCEL-205" type="update">add javadoc comments to
LineNumber.java and LineNumberTable.java.</action>
+ <action issue="BCEL-208" type="fix">Need to check for an empty
InstructionList.</action>
+ <action issue="BCEL-212" type="update">Inconsistent toString()
results.</action>
+ <action issue="BCEL-217" type="fix">long type instructions are not
searched by InstructionFinder using
+ regular expression.</action>
+ <action issue="BCEL-244" type="update" dev="ggregory">Update Java
requirement from 5 to 7.</action>
+ <action issue="BCEL-239" type="fix">Interfaces should not be used to
define constants.</action>
+ <action issue="BCEL-234" type="fix">Code must not swallow
Throwable.</action>
+ <action issue="BCEL-219" type="update" due-to="Maxim Degtyarev">
+ Make org.apache.bcel.classfile.ConstantPool.ConstantPool(DataInput)
+ public.
+ </action>
+ <action issue="BCEL-209" type="fix" due-to="Mark Roberts">
+ Bug fixes and improvements to InvokeDynamic and BootStrapMethods
+ implementation.
+ </action>
+ <action issue="BCEL-187" type="fix" due-to="Jérôme Leroux">
+ Verification error when an invoke references a method defined in
+ superclass.
+ </action>
+ <action issue="BCEL-218" type="fix" due-to="chas">
+ Remove ObjectType cache.
+ </action>
+ <action issue="BCEL-184" type="fix" due-to="Jérôme Leroux">
+ The verifier now checks if methods with a void return type attempt
+ to return an object.
+ </action>
+ <action issue="BCEL-207" type="fix" due-to="Mark Roberts">
+ MethodGen.removeLocalVariable now properly unreference the removed
+ variable from the targetters of the instruction handlers delimiting
+ the scope of the variable.
+ </action>
+ <action issue="BCEL-197" type="fix" due-to="Mark Roberts">
+ Utility.signatureToString() no longer throws a ClassFormatException
+ on TypeVariables found in generic signatures.
+ </action>
+ <action issue="BCEL-194" type="fix" due-to="Mark Roberts">
+ Removed the 'index' variable from the LocalVariableGen's hash code.
+ </action>
+ <action issue="BCEL-193" type="fix" dev="markt" due-to="Jérôme Leroux">
+ The verifier should not check for run time compatibility of objects
+ assigned to arrays.
+ </action>
+ <action issue="BCEL-188" type="fix" dev="markt" due-to="Jérôme Leroux">
+ Correct verification of the return value of a method.
+ </action>
+ <action issue="BCEL-186" type="fix" dev="sebb">
+ Performance degradation with the UTF8 cache. getInstance no longer
+ uses cache.
+ </action>
+ <action issue="BCEL-181" type="fix" dev="ggregory">
+ org.apache.bcel.util.ClassLoaderRepository.loadClass(String) leaks
+ input streams.
+ </action>
+ <action issue="BCEL-76" type="update">
+ Add parent type processing for ClassPath class.
+ </action>
+ <action issue="BCEL-83" type="update">
+ Add support for getResource and getResourceAsStream to ClassPath.
+ </action>
+ <action issue="BCEL-92" type="update">
+ Properly parse StackMapTable attributes in Java 6 classfiles.
+ </action>
+ <action issue="BCEL-104" type="update">
+ Javadoc overhaul.
+ </action>
+ <action issue="BCEL-119" type="update">
+ BCEL is unnecessarily slow.
+ </action>
+ <action issue="BCEL-157" type="update">
+ Add support for INVOKEDYNAMIC and MethodHandles.
+ </action>
+ <action issue="BCEL-160" type="update" dev="sebb">
+ Why using unstable sort at MethodGen.getLocalVariables() ?
+ </action>
+ <action issue="BCEL-163" type="update">
+ Incorporate patch file from Findbugs.
+ </action>
+ <action issue="BCEL-175" type="update">
+ Implement the MethodParameters attribute.
+ </action>
+ <action issue="BCEL-28" type="fix">
+ Mistake in "Peephole optimizer" example
+ at http://commons.apache.org/bcel/manual.html
+ </action>
+ <action issue="BCEL-74" type="fix">
+ BCEL cannot be used as java.system.class.loader.
+ </action>
+ <action issue="BCEL-77" type="fix">
+ XSLT transforms broken in Turkish Locale.
+ </action>
+ <action issue="BCEL-79" type="fix">
+ java.lang.ClassFormatError: LVTT entry for 'local' in class file
+ org/shiftone/jrat/test/dummy/CrashTestDummy does not match any LVT
+ entry
+ </action>
+ <action issue="BCEL-81" type="fix">
+ ClassParser.parse() throws NullPointerException if class does not
+ exist and ClassParser(String) constructor is used.
+ </action>
+ <action issue="BCEL-85" type="fix">
+ ArrayOutOfBoundsException in InstructionFinder.
+ </action>
+ <action issue="BCEL-87" type="fix">
+ Website: Incorrect URL for source; version 5.2 is not in the bug
+ page
+ </action>
+ <action issue="BCEL-88" type="fix">
+ bcelified method doesn't pass verification.
+ </action>
+ <action issue="BCEL-89" type="fix">
+ return type not verified by JustIce.
+ </action>
+ <action issue="BCEL-94" type="fix">
+ @since tag incorrect for Annotation classes in BCEL trunk.
+ </action>
+ <action issue="BCEL-95" type="fix">
+ InstructionFactory missing % operator for Float, Double.
+ </action>
+ <action issue="BCEL-96" type="fix">
+ Fields in Annotations and AnnotationEntry are inaccessible to
+ subclasses
+ </action>
+ <action issue="BCEL-97" type="fix">
+ Add support for getResources to ClassPath.
+ </action>
+ <action issue="BCEL-98" type="fix">
+ Two source files in repository are empty.
+ </action>
+ <action issue="BCEL-99" type="fix">
+ Maven POM file calls in apache regex but code does not use it.
+ </action>
+ <action issue="BCEL-100" type="fix">
+ ClassParser throws unintelligible Exception.
+ </action>
+ <action issue="BCEL-101" type="fix">
+ verifier raises an AssertionViolatedException when done against
+ Java 5 files with generics/annotations.
+ </action>
+ <action issue="BCEL-102" type="fix">
+ Verifier fails in pass 2 with "Number of LocalVariableTable
+ attributes of Code attribute" on static methods.
+ </action>
+ <action issue="BCEL-107" type="fix">
+ ParameterAnnotationEntries are read not dumped.
+ </action>
+ <action issue="BCEL-108" type="fix">
+ RuntimeVisible Annotations duplicated.
+ </action>
+ <action issue="BCEL-112" type="fix">
+ ARRAYLENGTH incorrectly not StackConsumer.
+ </action>
+ <action issue="BCEL-114" type="fix">
+ Error in method search() defined in
+ org.apache.bcel.util.InstructionFinder
+ </action>
+ <action issue="BCEL-115" type="fix">
+ Deleting all instructions of a list shows wrong behaviour.
+ </action>
+ <action issue="BCEL-120" type="fix">
+ Make BCEL JAR OSGi compatible.
+ </action>
+ <action issue="BCEL-122" type="fix">
+ ArrayIndexOutOfBoundsException thrown from TABLESWITCH.initFromFile.
+ </action>
+ <action issue="BCEL-124" type="fix">
+ tableswitch/lookupswitch invalid alignment of 4-byte operands.
+ </action>
+ <action issue="BCEL-125" type="fix">
+ Incorrect size calculation in InstructionFinder.
+ </action>
+ <action issue="BCEL-130" type="fix">
+ Class files containing "ParameterAnnotations" are dumped
+ incorrectly.
+ </action>
+ <action issue="BCEL-131" type="fix">
+ Class files containing "StackMapTable" attributes (on method code)
+ are dumped incorrectly.
+ </action>
+ <action issue="BCEL-132" type="fix">
+ org.apache.bcel.classfile.ClassParser: NullPointerException caused
+ by fileopen failed.
+ </action>
+ <action issue="BCEL-133" type="fix">
+ org.apache.bcel.classfile.ClassParser: NullPointerException caused
+ by invalid filename.
+ </action>
+ <action issue="BCEL-134" type="fix">
+ ExecutionVisitor doesn't support Class constant type for LDC and
+ LDC_W.
+ </action>
+ <action issue="BCEL-135" type="fix">
+ BCELifier issue: BCELFactory fails to handle float and long
+ constants.
+ </action>
+ <action issue="BCEL-137" type="fix">
+ "Invalid method signature: TT;" when using MethodGen for a method
+ having a generic parameter.
+ </action>
+ <action issue="BCEL-138" type="fix">
+ FieldInstruction.getFieldSize() doesn't decode Type.getTypeSize()
+ output.
+ </action>
+ <action issue="BCEL-140" type="fix">
+ org.apache.bcel.generic.Instruction.equals(Object) does not follow
+ Object.equals(Object) rules.
+ </action>
+ <action issue="BCEL-141" type="fix">
+ Select instructions should implement StackConsumer instead of
+ StackProducer.
+ </action>
+ <action issue="BCEL-143" type="fix">
+ Fix CPL License issues with EnclosingMethod.java and
+ LocalVariableTypeTable.java.
+ </action>
+ <action issue="BCEL-145" type="fix">
+ Type.getReturnTypeSize() doesn't decode Type.getTypeSize() output.
+ </action>
+ <action issue="BCEL-146" type="fix">
+ SyntheticRepository.loadClass() fails to close the inputStream.
+ </action>
+ <action issue="BCEL-148" type="fix">
+ BCELifier produces incorrect code for methods containing loads of
+ class literals from constant pool.
+ </action>
+ <action issue="BCEL-151" type="fix">
+ Code attribute size not updated.
+ </action>
+ <action issue="BCEL-152" type="fix">
+ Incorrect link for Jasmin assembler language.
+ </action>
+ <action issue="BCEL-153" type="fix" dev="sebb">
+ Examples not present in source or binary downloads.
+ </action>
+ <action issue="BCEL-154" type="fix">
+ ClassParser.parse() generates NPE if it cannot open the file.
+ </action>
+ <action issue="BCEL-155" type="fix">
+ InstConstraintVisitor does not handle class constants.
+ </action>
+ <action issue="BCEL-156" type="fix">
+ Pass3bVerifier crashes on empty methods.
+ </action>
+ <action issue="BCEL-159" type="fix">
+ LocalVariableGen.getLocalVariable() computes incorrect length.
+ </action>
+ <action issue="BCEL-164" type="fix">
+ Method does not have a method to access parameter annotations.
+ </action>
+ <action issue="BCEL-167" type="fix">
+ ClassPath.getResource does not correctly perform URL escaping.
+ </action>
+ <action issue="BCEL-173" type="fix">
+ ClassParser fails to parse JDK classes in Java 8:
+ ClassFormatException: Invalid byte tag in constant pool.
+ </action>
+ <action issue="BCEL-174" type="fix">
+ Verification of interfaces with default methods fails with Java 8.
+ </action>
+ <action issue="BCEL-177" type="fix" dev="markt">
+ When reading the number of parameters in a MethodParameters
+ structure only read a single byte as per the JVM specification.
+ </action>
+ </release>
+ </body>
+</document>
diff --git a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
index fba2d78..ddd7a9f 100644
--- a/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
+++ b/src/main/java/org/apache/bcel/classfile/FieldOrMethod.java
@@ -1,293 +1,295 @@
-/*
- * 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.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.apache.bcel.Const;
-
-/**
- * Abstract super class for fields and methods.
- *
- * @version $Id$
- */
-public abstract class FieldOrMethod extends AccessFlags implements Cloneable,
Node {
-
- /**
- * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
- */
- @java.lang.Deprecated
- protected int name_index; // Points to field name in constant pool
-
- /**
- * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
- */
- @java.lang.Deprecated
- protected int signature_index; // Points to encoded signature
-
- /**
- * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
- */
- @java.lang.Deprecated
- protected Attribute[] attributes; // Collection of attributes
-
- /**
- * @deprecated (since 6.0) will be removed (not needed)
- */
- @java.lang.Deprecated
- protected int attributes_count; // No. of attributes
-
- // @since 6.0
- private AnnotationEntry[] annotationEntries; // annotations defined on the
field or method
-
- /**
- * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
- */
- @java.lang.Deprecated
- protected ConstantPool constant_pool;
-
- private String signatureAttributeString = null;
- private boolean searchedForSignatureAttribute = false;
-
- FieldOrMethod() {
- }
-
-
- /**
- * Initialize from another object. Note that both objects use the same
- * references (shallow copy). Use clone() for a physical copy.
- */
- protected FieldOrMethod(final FieldOrMethod c) {
- this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(),
c.getAttributes(), c
- .getConstantPool());
- }
-
-
- /**
- * Construct object from file stream.
- * @param file Input stream
- * @throws IOException
- * @throws ClassFormatException
- * @deprecated (6.0) Use {@link #FieldOrMethod(java.io.DataInput,
ConstantPool)} instead.
- */
- @java.lang.Deprecated
- protected FieldOrMethod(final DataInputStream file, final ConstantPool
constant_pool) throws IOException,
- ClassFormatException {
- this((DataInput) file, constant_pool);
- }
-
- /**
- * Construct object from file stream.
- * @param file Input stream
- * @throws IOException
- * @throws ClassFormatException
- */
- protected FieldOrMethod(final DataInput file, final ConstantPool
constant_pool) throws IOException, ClassFormatException {
- this(file.readUnsignedShort(), file.readUnsignedShort(),
file.readUnsignedShort(), null,
- constant_pool);
- final int attributes_count = file.readUnsignedShort();
- attributes = new Attribute[attributes_count];
- for (int i = 0; i < attributes_count; i++) {
- attributes[i] = Attribute.readAttribute(file, constant_pool);
- }
- this.attributes_count = attributes_count; // init deprecated field
- }
-
-
- /**
- * @param access_flags Access rights of method
- * @param name_index Points to field name in constant pool
- * @param signature_index Points to encoded signature
- * @param attributes Collection of attributes
- * @param constant_pool Array of constants
- */
- protected FieldOrMethod(final int access_flags, final int name_index,
final int signature_index,
- final Attribute[] attributes, final ConstantPool constant_pool) {
- super(access_flags);
- this.name_index = name_index;
- this.signature_index = signature_index;
- this.constant_pool = constant_pool;
- setAttributes(attributes);
- }
-
-
- /**
- * Dump object to file stream on binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump( final DataOutputStream file ) throws IOException {
- file.writeShort(super.getAccessFlags());
- file.writeShort(name_index);
- file.writeShort(signature_index);
- file.writeShort(attributes.length);
- for (final Attribute attribute : attributes) {
- attribute.dump(file);
- }
- }
-
-
- /**
- * @return Collection of object attributes.
- */
- public final Attribute[] getAttributes() {
- return attributes;
- }
-
-
- /**
- * @param attributes Collection of object attributes.
- */
- public final void setAttributes( final Attribute[] attributes ) {
- this.attributes = attributes;
- this.attributes_count = attributes != null ? attributes.length : 0; //
init deprecated field
- }
-
-
- /**
- * @return Constant pool used by this object.
- */
- public final ConstantPool getConstantPool() {
- return constant_pool;
- }
-
-
- /**
- * @param constant_pool Constant pool to be used for this object.
- */
- public final void setConstantPool( final ConstantPool constant_pool ) {
- this.constant_pool = constant_pool;
- }
-
-
- /**
- * @return Index in constant pool of object's name.
- */
- public final int getNameIndex() {
- return name_index;
- }
-
-
- /**
- * @param name_index Index in constant pool of object's name.
- */
- public final void setNameIndex( final int name_index ) {
- this.name_index = name_index;
- }
-
-
- /**
- * @return Index in constant pool of field signature.
- */
- public final int getSignatureIndex() {
- return signature_index;
- }
-
-
- /**
- * @param signature_index Index in constant pool of field signature.
- */
- public final void setSignatureIndex( final int signature_index ) {
- this.signature_index = signature_index;
- }
-
-
- /**
- * @return Name of object, i.e., method name or field name
- */
- public final String getName() {
- ConstantUtf8 c;
- c = (ConstantUtf8) constant_pool.getConstant(name_index,
Const.CONSTANT_Utf8);
- return c.getBytes();
- }
-
-
- /**
- * @return String representation of object's type signature (java style)
- */
- public final String getSignature() {
- ConstantUtf8 c;
- c = (ConstantUtf8) constant_pool.getConstant(signature_index,
Const.CONSTANT_Utf8);
- return c.getBytes();
- }
-
-
- /**
- * @return deep copy of this field
- */
- protected FieldOrMethod copy_( final ConstantPool _constant_pool ) {
- FieldOrMethod c = null;
-
- try {
- c = (FieldOrMethod)clone();
- } catch(final CloneNotSupportedException e) {
- // ignored, but will cause NPE ...
- }
-
- c.constant_pool = constant_pool;
- c.attributes = new Attribute[attributes.length];
- c.attributes_count = attributes_count; // init deprecated field
-
- for (int i = 0; i < attributes.length; i++) {
- c.attributes[i] = attributes[i].copy(constant_pool);
- }
-
- return c;
- }
-
- /**
- * @return Annotations on the field or method
- * @since 6.0
- */
- public AnnotationEntry[] getAnnotationEntries() {
- if (annotationEntries == null) {
- annotationEntries =
AnnotationEntry.createAnnotationEntries(getAttributes());
- }
-
- return annotationEntries;
- }
-
- /**
- * Hunts for a signature attribute on the member and returns its contents.
So where the 'regular' signature
- * may be (Ljava/util/Vector;)V the signature attribute may in fact say
'Ljava/lang/Vector<Ljava/lang/String>;'
- * Coded for performance - searches for the attribute only when requested
- only searches for it once.
- * @since 6.0
- */
- public final String getGenericSignature()
- {
- if (!searchedForSignatureAttribute)
- {
- boolean found = false;
- for (int i = 0; !found && i < attributes.length; i++)
- {
- if (attributes[i] instanceof Signature)
- {
- signatureAttributeString = ((Signature) attributes[i])
- .getSignature();
- found = true;
- }
- }
- searchedForSignatureAttribute = true;
- }
- return signatureAttributeString;
- }
-}
+/*
+ * 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.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.bcel.Const;
+
+/**
+ * Abstract super class for fields and methods.
+ *
+ * @version $Id$
+ */
+public abstract class FieldOrMethod extends AccessFlags implements Cloneable,
Node {
+
+ /**
+ * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
+ */
+ @java.lang.Deprecated
+ protected int name_index; // Points to field name in constant pool
+
+ /**
+ * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
+ */
+ @java.lang.Deprecated
+ protected int signature_index; // Points to encoded signature
+
+ /**
+ * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
+ */
+ @java.lang.Deprecated
+ protected Attribute[] attributes; // Collection of attributes
+
+ /**
+ * @deprecated (since 6.0) will be removed (not needed)
+ */
+ @java.lang.Deprecated
+ protected int attributes_count; // No. of attributes
+
+ // @since 6.0
+ private AnnotationEntry[] annotationEntries; // annotations defined on the
field or method
+
+ /**
+ * @deprecated (since 6.0) will be made private; do not access directly,
use getter/setter
+ */
+ @java.lang.Deprecated
+ protected ConstantPool constant_pool;
+
+ private String signatureAttributeString = null;
+ private boolean searchedForSignatureAttribute = false;
+
+ FieldOrMethod() {
+ }
+
+
+ /**
+ * Initialize from another object. Note that both objects use the same
+ * references (shallow copy). Use clone() for a physical copy.
+ */
+ protected FieldOrMethod(final FieldOrMethod c) {
+ this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(),
c.getAttributes(), c
+ .getConstantPool());
+ }
+
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throws IOException
+ * @throws ClassFormatException
+ * @deprecated (6.0) Use {@link #FieldOrMethod(java.io.DataInput,
ConstantPool)} instead.
+ */
+ @java.lang.Deprecated
+ protected FieldOrMethod(final DataInputStream file, final ConstantPool
constant_pool) throws IOException,
+ ClassFormatException {
+ this((DataInput) file, constant_pool);
+ }
+
+ /**
+ * Construct object from file stream.
+ * @param file Input stream
+ * @throws IOException
+ * @throws ClassFormatException
+ */
+ protected FieldOrMethod(final DataInput file, final ConstantPool
constant_pool) throws IOException, ClassFormatException {
+ this(file.readUnsignedShort(), file.readUnsignedShort(),
file.readUnsignedShort(), null,
+ constant_pool);
+ final int attributes_count = file.readUnsignedShort();
+ attributes = new Attribute[attributes_count];
+ for (int i = 0; i < attributes_count; i++) {
+ attributes[i] = Attribute.readAttribute(file, constant_pool);
+ }
+ this.attributes_count = attributes_count; // init deprecated field
+ }
+
+
+ /**
+ * @param access_flags Access rights of method
+ * @param name_index Points to field name in constant pool
+ * @param signature_index Points to encoded signature
+ * @param attributes Collection of attributes
+ * @param constant_pool Array of constants
+ */
+ protected FieldOrMethod(final int access_flags, final int name_index,
final int signature_index,
+ final Attribute[] attributes, final ConstantPool constant_pool) {
+ super(access_flags);
+ this.name_index = name_index;
+ this.signature_index = signature_index;
+ this.constant_pool = constant_pool;
+ setAttributes(attributes);
+ }
+
+
+ /**
+ * Dump object to file stream on binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ public final void dump(final DataOutputStream file) throws IOException {
+ file.writeShort(super.getAccessFlags());
+ file.writeShort(name_index);
+ file.writeShort(signature_index);
+ file.writeShort(attributes_count);
+ if (attributes != null) {
+ for (final Attribute attribute : attributes) {
+ attribute.dump(file);
+ }
+ }
+ }
+
+
+ /**
+ * @return Collection of object attributes.
+ */
+ public final Attribute[] getAttributes() {
+ return attributes;
+ }
+
+
+ /**
+ * @param attributes Collection of object attributes.
+ */
+ public final void setAttributes( final Attribute[] attributes ) {
+ this.attributes = attributes;
+ this.attributes_count = attributes != null ? attributes.length : 0; //
init deprecated field
+ }
+
+
+ /**
+ * @return Constant pool used by this object.
+ */
+ public final ConstantPool getConstantPool() {
+ return constant_pool;
+ }
+
+
+ /**
+ * @param constant_pool Constant pool to be used for this object.
+ */
+ public final void setConstantPool( final ConstantPool constant_pool ) {
+ this.constant_pool = constant_pool;
+ }
+
+
+ /**
+ * @return Index in constant pool of object's name.
+ */
+ public final int getNameIndex() {
+ return name_index;
+ }
+
+
+ /**
+ * @param name_index Index in constant pool of object's name.
+ */
+ public final void setNameIndex( final int name_index ) {
+ this.name_index = name_index;
+ }
+
+
+ /**
+ * @return Index in constant pool of field signature.
+ */
+ public final int getSignatureIndex() {
+ return signature_index;
+ }
+
+
+ /**
+ * @param signature_index Index in constant pool of field signature.
+ */
+ public final void setSignatureIndex( final int signature_index ) {
+ this.signature_index = signature_index;
+ }
+
+
+ /**
+ * @return Name of object, i.e., method name or field name
+ */
+ public final String getName() {
+ ConstantUtf8 c;
+ c = (ConstantUtf8) constant_pool.getConstant(name_index,
Const.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+
+ /**
+ * @return String representation of object's type signature (java style)
+ */
+ public final String getSignature() {
+ ConstantUtf8 c;
+ c = (ConstantUtf8) constant_pool.getConstant(signature_index,
Const.CONSTANT_Utf8);
+ return c.getBytes();
+ }
+
+
+ /**
+ * @return deep copy of this field
+ */
+ protected FieldOrMethod copy_( final ConstantPool _constant_pool ) {
+ FieldOrMethod c = null;
+
+ try {
+ c = (FieldOrMethod)clone();
+ } catch(final CloneNotSupportedException e) {
+ // ignored, but will cause NPE ...
+ }
+
+ c.constant_pool = constant_pool;
+ c.attributes = new Attribute[attributes.length];
+ c.attributes_count = attributes_count; // init deprecated field
+
+ for (int i = 0; i < attributes.length; i++) {
+ c.attributes[i] = attributes[i].copy(constant_pool);
+ }
+
+ return c;
+ }
+
+ /**
+ * @return Annotations on the field or method
+ * @since 6.0
+ */
+ public AnnotationEntry[] getAnnotationEntries() {
+ if (annotationEntries == null) {
+ annotationEntries =
AnnotationEntry.createAnnotationEntries(getAttributes());
+ }
+
+ return annotationEntries;
+ }
+
+ /**
+ * Hunts for a signature attribute on the member and returns its contents.
So where the 'regular' signature
+ * may be (Ljava/util/Vector;)V the signature attribute may in fact say
'Ljava/lang/Vector<Ljava/lang/String>;'
+ * Coded for performance - searches for the attribute only when requested
- only searches for it once.
+ * @since 6.0
+ */
+ public final String getGenericSignature()
+ {
+ if (!searchedForSignatureAttribute)
+ {
+ boolean found = false;
+ for (int i = 0; !found && i < attributes.length; i++)
+ {
+ if (attributes[i] instanceof Signature)
+ {
+ signatureAttributeString = ((Signature) attributes[i])
+ .getSignature();
+ found = true;
+ }
+ }
+ searchedForSignatureAttribute = true;
+ }
+ return signatureAttributeString;
+ }
+}