Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jason Zaugg
asm
Commits
9d468c94
Commit
9d468c94
authored
May 02, 2018
by
Eric Bruneton
Browse files
Merge branch 'ASM7_NESTMATES'
parents
bc615163
76941586
Changes
66
Hide whitespace changes
Inline
Side-by-side
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java
View file @
9d468c94
...
...
@@ -56,8 +56,9 @@ public class BasicInterpreter extends Interpreter<BasicValue> implements Opcodes
public
static
final
Type
NULL_TYPE
=
Type
.
getObjectType
(
"null"
);
/**
* Constructs a new {@link BasicInterpreter} for the latest ASM API version. <i>Subclasses must not
* use this constructor</i>. Instead, they must use the {@link #BasicInterpreter(int)} version.
* Constructs a new {@link BasicInterpreter} for the latest ASM API version. <i>Subclasses must
* not use this constructor</i>. Instead, they must use the {@link #BasicInterpreter(int)}
* version.
*/
public
BasicInterpreter
()
{
super
(
ASM6
);
...
...
@@ -70,8 +71,8 @@ public class BasicInterpreter extends Interpreter<BasicValue> implements Opcodes
* Constructs a new {@link BasicInterpreter}.
*
* @param api the ASM API version supported by this interpreter. Must be one of {@link
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
*/
protected
BasicInterpreter
(
final
int
api
)
{
super
(
api
);
...
...
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java
View file @
9d468c94
...
...
@@ -44,8 +44,8 @@ import org.objectweb.asm.tree.MethodInsnNode;
public
class
BasicVerifier
extends
BasicInterpreter
{
/**
* Constructs a new {@link BasicVerifier} for the latest ASM API version. <i>Subclasses must not
use
* this constructor</i>. Instead, they must use the {@link #BasicVerifier(int)} version.
* Constructs a new {@link BasicVerifier} for the latest ASM API version. <i>Subclasses must not
*
use
this constructor</i>. Instead, they must use the {@link #BasicVerifier(int)} version.
*/
public
BasicVerifier
()
{
super
(
ASM6
);
...
...
@@ -58,8 +58,8 @@ public class BasicVerifier extends BasicInterpreter {
* Constructs a new {@link BasicVerifier}.
*
* @param api the ASM API version supported by this interpreter. Must be one of {@link
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
*/
protected
BasicVerifier
(
final
int
api
)
{
super
(
api
);
...
...
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Interpreter.java
View file @
9d468c94
...
...
@@ -46,8 +46,8 @@ public abstract class Interpreter<V extends Value> {
/**
* The ASM API version supported by this interpreter. The value of this field must be one of
* {@link org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* {@link org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
*/
protected
final
int
api
;
...
...
@@ -55,8 +55,8 @@ public abstract class Interpreter<V extends Value> {
* Constructs a new {@link Interpreter}.
*
* @param api the ASM API version supported by this interpreter. Must be one of {@link
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
*/
protected
Interpreter
(
final
int
api
)
{
this
.
api
=
api
;
...
...
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java
View file @
9d468c94
...
...
@@ -105,8 +105,8 @@ public class SimpleVerifier extends BasicVerifier {
* loaded into the JVM since it may be incorrect.
*
* @param api the ASM API version supported by this verifier. Must be one of {@link
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
* @param currentClass the type of the class to be verified.
* @param currentSuperClass the type of the super class of the class to be verified.
* @param currentClassInterfaces the types of the interfaces directly implemented by the class to
...
...
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java
View file @
9d468c94
...
...
@@ -47,8 +47,9 @@ import org.objectweb.asm.tree.MethodInsnNode;
public
class
SourceInterpreter
extends
Interpreter
<
SourceValue
>
implements
Opcodes
{
/**
* Constructs a new {@link SourceInterpreter} for the latest ASM API version. <i>Subclasses must not
* use this constructor</i>. Instead, they must use the {@link #SourceInterpreter(int)} version.
* Constructs a new {@link SourceInterpreter} for the latest ASM API version. <i>Subclasses must
* not use this constructor</i>. Instead, they must use the {@link #SourceInterpreter(int)}
* version.
*/
public
SourceInterpreter
()
{
super
(
ASM6
);
...
...
@@ -61,8 +62,8 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
* Constructs a new {@link SourceInterpreter}.
*
* @param api the ASM API version supported by this interpreter. Must be one of {@link
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
*/
protected
SourceInterpreter
(
final
int
api
)
{
super
(
api
);
...
...
asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java
View file @
9d468c94
...
...
@@ -523,7 +523,12 @@ public class SimpleVerifierTest extends AsmTest implements Opcodes {
ClassNode
classNode
=
new
ClassNode
();
new
ClassReader
(
classParameter
.
getBytes
()).
accept
(
classNode
,
0
);
for
(
MethodNode
methodNode
:
classNode
.
methods
)
{
Analyzer
<
BasicValue
>
analyzer
=
new
Analyzer
<
BasicValue
>(
new
SimpleVerifier
());
Analyzer
<
BasicValue
>
analyzer
=
new
Analyzer
<
BasicValue
>(
new
SimpleVerifier
(
Type
.
getObjectType
(
classNode
.
name
),
Type
.
getObjectType
(
classNode
.
superName
),
(
classNode
.
access
&
Opcodes
.
ACC_INTERFACE
)
!=
0
));
analyzer
.
analyze
(
classNode
.
name
,
methodNode
);
}
}
...
...
asm-commons/src/main/java/org/objectweb/asm/commons/AdviceAdapter.java
View file @
9d468c94
...
...
@@ -97,7 +97,7 @@ public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
* Constructs a new {@link AdviceAdapter}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param methodVisitor the method visitor to which this adapter delegates calls.
* @param access the method's access flags (see {@link Opcodes}).
* @param name the method's name.
...
...
@@ -641,4 +641,4 @@ public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
* Opcodes#ATHROW}.
*/
protected
void
onMethodExit
(
final
int
opcode
)
{}
}
}
\ No newline at end of file
asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java
View file @
9d468c94
...
...
@@ -126,7 +126,7 @@ public class AnalyzerAdapter extends MethodVisitor {
* Constructs a new {@link AnalyzerAdapter}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param owner the owner's class name.
* @param access the method's access flags (see {@link Opcodes}).
* @param name the method's name.
...
...
asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java
View file @
9d468c94
...
...
@@ -67,8 +67,8 @@ public class ClassRemapper extends ClassVisitor {
* Constructs a new {@link ClassRemapper}.
*
* @param api the ASM API version supported by this remapper. Must be one of {@link
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
or
{@link
* org.objectweb.asm.Opcodes#ASM6}.
* org.objectweb.asm.Opcodes#ASM4}, {@link org.objectweb.asm.Opcodes#ASM5}
,
{@link
* org.objectweb.asm.Opcodes#ASM6}
or {@link org.objectweb.asm.Opcodes#ASM7_EXPERIMENTAL}
.
* @param classVisitor the class visitor this remapper must deleted to.
* @param remapper the remapper to use to remap the types in the visited class.
*/
...
...
@@ -181,6 +181,16 @@ public class ClassRemapper extends ClassVisitor {
descriptor
==
null
?
null
:
remapper
.
mapMethodDesc
(
descriptor
));
}
@Override
public
void
visitNestHostExperimental
(
final
String
nestHost
)
{
super
.
visitNestHostExperimental
(
remapper
.
mapType
(
nestHost
));
}
@Override
public
void
visitNestMemberExperimental
(
final
String
nestMember
)
{
super
.
visitNestMemberExperimental
(
remapper
.
mapType
(
nestMember
));
}
/**
* Constructs a new remapper for fields. The default implementation of this method returns a new
* {@link FieldRemapper}.
...
...
@@ -224,4 +234,4 @@ public class ClassRemapper extends ClassVisitor {
protected
ModuleVisitor
createModuleRemapper
(
final
ModuleVisitor
moduleVisitor
)
{
return
new
ModuleRemapper
(
api
,
moduleVisitor
,
remapper
);
}
}
}
\ No newline at end of file
asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java
View file @
9d468c94
...
...
@@ -211,7 +211,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
* Constructs a new {@link GeneratorAdapter}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param methodVisitor the method visitor to which this adapter delegates calls.
* @param access the method's access flags (see {@link Opcodes}).
* @param name the method's name.
...
...
@@ -1420,4 +1420,4 @@ public class GeneratorAdapter extends LocalVariablesSorter {
}
mark
(
catchLabel
);
}
}
}
\ No newline at end of file
asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java
View file @
9d468c94
...
...
@@ -62,7 +62,7 @@ public class InstructionAdapter extends MethodVisitor {
* Constructs a new {@link InstructionAdapter}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param methodVisitor the method visitor to which this adapter delegates calls.
*/
protected
InstructionAdapter
(
final
int
api
,
final
MethodVisitor
methodVisitor
)
{
...
...
@@ -1175,4 +1175,4 @@ public class InstructionAdapter extends MethodVisitor {
public
void
mark
(
final
Label
label
)
{
mv
.
visitLabel
(
label
);
}
}
}
\ No newline at end of file
asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java
View file @
9d468c94
...
...
@@ -108,7 +108,7 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes {
* Constructs a new {@link JSRInlinerAdapter}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param methodVisitor the method visitor to send the resulting inlined method code to, or <code>
* null</code>.
* @param access the method's access flags.
...
...
@@ -560,4 +560,4 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes {
throw
new
UnsupportedOperationException
();
}
}
}
}
\ No newline at end of file
asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java
View file @
9d468c94
...
...
@@ -91,7 +91,7 @@ public class LocalVariablesSorter extends MethodVisitor {
* Constructs a new {@link LocalVariablesSorter}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param access access flags of the adapted method.
* @param descriptor the method's descriptor (see {@link Type}).
* @param methodVisitor the method visitor to which this adapter delegates calls.
...
...
asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java
View file @
9d468c94
...
...
@@ -160,7 +160,7 @@ public class SerialVersionUIDAdder extends ClassVisitor {
* Constructs a new {@link SerialVersionUIDAdder}.
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM
6
}.
* Opcodes#ASM4}, {@link Opcodes#ASM5}
, {@link Opcodes#ASM6}
or {@link Opcodes#ASM
7_EXPERIMENTAL
}.
* @param classVisitor a {@link ClassVisitor} to which this visitor will delegate calls.
*/
protected
SerialVersionUIDAdder
(
final
int
api
,
final
ClassVisitor
classVisitor
)
{
...
...
@@ -483,4 +483,4 @@ public class SerialVersionUIDAdder extends ClassVisitor {
this
.
descriptor
=
descriptor
;
}
}
}
}
\ No newline at end of file
asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java
View file @
9d468c94
...
...
@@ -151,7 +151,7 @@ public class AnalyzerAdapterTest extends AsmTest {
private
boolean
hasOriginalFrame
;
AnalyzedFramesInserter
(
final
MethodVisitor
methodVisitor
)
{
super
(
Opcodes
.
ASM
6
,
methodVisitor
);
super
(
Opcodes
.
ASM
7_EXPERIMENTAL
,
methodVisitor
);
}
void
setAnalyzerAdapter
(
final
AnalyzerAdapter
analyzerAdapter
)
{
...
...
@@ -288,4 +288,4 @@ public class AnalyzerAdapterTest extends AsmTest {
super
.
visitMultiANewArrayInsn
(
descriptor
,
numDimensions
);
}
}
}
}
\ No newline at end of file
asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUIDAdderTest.java
View file @
9d468c94
...
...
@@ -110,7 +110,7 @@ public class SerialVersionUIDAdderTest extends AsmTest {
final
PrecompiledClass
classParameter
,
final
Api
apiParameter
)
{
ClassReader
classReader
=
new
ClassReader
(
classParameter
.
getBytes
());
ClassWriter
classWriter
=
new
ClassWriter
(
0
);
classReader
.
accept
(
new
SerialVersionUIDAdder
(
classWriter
),
0
);
classReader
.
accept
(
new
SerialVersionUIDAdder
(
Opcodes
.
ASM7_EXPERIMENTAL
,
classWriter
)
{}
,
0
);
if
((
classReader
.
getAccess
()
&
Opcodes
.
ACC_ENUM
)
==
0
)
{
assertThatClass
(
classWriter
.
toByteArray
()).
contains
(
"serialVersionUID"
);
}
...
...
asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java
View file @
9d468c94
...
...
@@ -49,7 +49,7 @@ import java.util.stream.Stream;
/**
* Base class for the ASM tests. ASM can be used to read, write or transform any Java class, ranging
* from very old (e.g. JDK 1.3) to very recent classes, containing all possible class file
* structures. ASM can also be used with different variants of its API (ASM4, ASM5
or
ASM6). In
* structures. ASM can also be used with different variants of its API (ASM4, ASM5
,
ASM6
, etc
). In
* order to test it thoroughly, it is therefore necessary to run read, write and transform tests,
* for each API version, and for each class in a set of classes containing all possible class file
* structures. The purpose of this class is to automate this process. For this it relies on:
...
...
@@ -65,8 +65,8 @@ import java.util.stream.Stream;
* API) tuple.
* </ul>
*
* For instance, to run a test on all the precompiled classes, with
both
the A
SM5 and the ASM6 API,
*
use a subclass
such as the following:
*
<p>
For instance, to run a test on all the precompiled classes, with
all
the A
PIs, use a subclass
* such as the following:
*
* <pre>
* public class MyParameterizedTest extends AsmTest {
...
...
@@ -128,7 +128,9 @@ public abstract class AsmTest {
JDK8_ARTIFICIAL_STRUCTURES
(
"jdk8.ArtificialStructures"
),
JDK8_INNER_CLASS
(
"jdk8.AllStructures$InnerClass"
),
JDK8_LARGE_METHOD
(
"jdk8.LargeMethod"
),
JDK9_MODULE
(
"jdk9.module-info"
);
JDK9_MODULE
(
"jdk9.module-info"
),
JDK11_ALL_STRUCTURES
(
"jdk11.AllStructures"
),
JDK11_ALL_STRUCTURES_NESTED
(
"jdk11.AllStructures$Nested"
);
private
final
String
name
;
...
...
@@ -155,10 +157,13 @@ public abstract class AsmTest {
* @return whether this class was compiled with a JDK which is more recent than api.
*/
public
boolean
isMoreRecentThan
(
final
Api
api
)
{
if
(
name
.
startsWith
(
"jdk8"
)
&&
api
.
value
()
<
Api
.
ASM5
.
value
())
{
if
(
name
.
startsWith
(
"jdk8
.
"
)
&&
api
.
value
()
<
Api
.
ASM5
.
value
())
{
return
true
;
}
return
name
.
startsWith
(
"jdk9"
)
&&
api
.
value
()
<
Api
.
ASM6
.
value
();
if
(
name
.
startsWith
(
"jdk9."
)
&&
api
.
value
()
<
Api
.
ASM6
.
value
())
{
return
true
;
}
return
name
.
startsWith
(
"jdk11."
)
&&
api
.
value
()
<
Api
.
ASM7
.
value
();
}
/**
...
...
@@ -169,9 +174,12 @@ public abstract class AsmTest {
* less than 9.
*/
public
boolean
isMoreRecentThanCurrentJdk
()
{
if
(
name
.
startsWith
(
"jdk9"
))
{
if
(
name
.
startsWith
(
"jdk9
.
"
))
{
return
getMajorJavaVersion
()
<
9
;
}
if
(
name
.
startsWith
(
"jdk11."
))
{
return
getMajorJavaVersion
()
<
11
;
}
return
false
;
}
...
...
@@ -226,7 +234,8 @@ public abstract class AsmTest {
public
enum
Api
{
ASM4
(
"ASM4"
,
4
<<
16
),
ASM5
(
"ASM5"
,
5
<<
16
),
ASM6
(
"ASM6"
,
6
<<
16
);
ASM6
(
"ASM6"
,
6
<<
16
),
ASM7
(
"ASM7"
,
1
<<
24
|
7
<<
16
);
private
final
String
name
;
private
final
int
value
;
...
...
@@ -239,7 +248,7 @@ public abstract class AsmTest {
/**
* Returns the int value of this version, as expected by ASM.
*
* @return one of the ASM4, ASM5 or ASM
6
constants from the ASM Opcodes interface.
* @return one of the ASM4, ASM5
, ASM6
or ASM
7
constants from the ASM Opcodes interface.
*/
public
int
value
()
{
return
value
;
...
...
@@ -248,7 +257,7 @@ public abstract class AsmTest {
/**
* Returns a human readable symbol corresponding to this version.
*
* @return one of "ASM4", "ASM5" or "ASM
6
".
* @return one of "ASM4", "ASM5"
, "ASM6"
or "ASM
7
".
*/
@Override
public
String
toString
()
{
...
...
@@ -273,10 +282,10 @@ public abstract class AsmTest {
* with <tt>@MethodSource("allClassesAndLatestApi")</tt> will be executed on all the precompiled
* classes, with the latest api.
*
* @return all the possible (precompiledClass, ASM
6
) pairs, for all the precompiled classes.
* @return all the possible (precompiledClass, ASM
7
) pairs, for all the precompiled classes.
*/
public
static
Stream
<
Arguments
>
allClassesAndLatestApi
()
{
return
classesAndApis
(
Api
.
ASM
6
);
return
classesAndApis
(
Api
.
ASM
7
);
}
private
static
Stream
<
Arguments
>
classesAndApis
(
final
Api
...
apis
)
{
...
...
asm-test/src/main/java/org/objectweb/asm/test/ClassDump.java
View file @
9d468c94
...
...
@@ -150,7 +150,7 @@ class ClassDump {
builder
.
add
(
"magic: "
,
parser
.
u4
());
builder
.
add
(
"minor_version: "
,
parser
.
u2
());
int
majorVersion
=
parser
.
u2
();
if
(
majorVersion
>
=
/* V1
0
= */
5
4
)
{
if
(
majorVersion
>
/* V1
1
= */
5
5
)
{
throw
new
IOException
(
"Unsupported class version"
);
}
builder
.
add
(
"major_version: "
,
majorVersion
);
...
...
@@ -188,7 +188,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.1">JVMS
* 4.1</a>
*/
private
static
void
dumpAttributeList
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpAttributeList
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
attributeCount
=
builder
.
add
(
"attributes_count: "
,
parser
.
u2
());
SortedBuilder
sortedBuilder
=
builder
.
addSortedBuilder
();
for
(
int
i
=
0
;
i
<
attributeCount
;
++
i
)
{
...
...
@@ -206,7 +207,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.4">JVMS
* 4.4</a>
*/
private
static
CpInfo
parseCpInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
private
static
CpInfo
parseCpInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
int
tag
=
parser
.
u1
();
switch
(
tag
)
{
case
7
:
...
...
@@ -407,7 +409,8 @@ class ClassDump {
* @param classContext a context to lookup constant pool items from their index.
* @throws IOException if the class can't be parsed.
*/
ConstantInterfaceMethodRefInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
ConstantInterfaceMethodRefInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
super
(
classContext
);
this
.
classIndex
=
parser
.
u2
();
this
.
nameAndTypeIndex
=
parser
.
u2
();
...
...
@@ -551,7 +554,8 @@ class ClassDump {
* @param classContext a context to lookup constant pool items from their index.
* @throws IOException if the class can't be parsed.
*/
ConstantNameAndTypeInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
ConstantNameAndTypeInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
super
(
classContext
);
this
.
nameIndex
=
parser
.
u2
();
this
.
descriptorIndex
=
parser
.
u2
();
...
...
@@ -600,7 +604,8 @@ class ClassDump {
* @param classContext a context to lookup constant pool items from their index.
* @throws IOException if the class can't be parsed.
*/
ConstantMethodHandleInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
ConstantMethodHandleInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
super
(
classContext
);
this
.
referenceKind
=
parser
.
u1
();
this
.
referenceIndex
=
parser
.
u2
();
...
...
@@ -628,7 +633,8 @@ class ClassDump {
* @param classContext a context to lookup constant pool items from their index.
* @throws IOException if the class can't be parsed.
*/
ConstantMethodTypeInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
ConstantMethodTypeInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
super
(
classContext
);
this
.
descriptorIndex
=
parser
.
u2
();
}
...
...
@@ -656,7 +662,8 @@ class ClassDump {
* @param classContext a context to lookup constant pool items from their index.
* @throws IOException if the class can't be parsed.
*/
ConstantInvokeDynamicInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
ConstantInvokeDynamicInfo
(
final
Parser
parser
,
final
ClassContext
classContext
)
throws
IOException
{
super
(
classContext
);
this
.
bootstrapMethodAttrIndex
=
parser
.
u2
();
this
.
nameAndTypeIndex
=
parser
.
u2
();
...
...
@@ -749,7 +756,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.6">JVMS
* 4.6</a>
*/
private
static
void
dumpMethodInfo
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpMethodInfo
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
// method_info has the same top level structure as field_info.
dumpFieldInfo
(
parser
,
builder
);
}
...
...
@@ -825,6 +833,10 @@ class ClassDump {
dumpModulePackagesAttribute
(
parser
,
builder
);
}
else
if
(
attributeName
.
equals
(
"ModuleMainClass"
))
{
dumpModuleMainClassAttribute
(
parser
,
builder
);
}
else
if
(
attributeName
.
equals
(
"NestHost"
))
{
dumpNestHostAttribute
(
parser
,
builder
);
}
else
if
(
attributeName
.
equals
(
"NestMembers"
))
{
dumpNestMembersAttribute
(
parser
,
builder
);
}
else
if
(
attributeName
.
equals
(
"StackMap"
))
{
dumpStackMapAttribute
(
parser
,
builder
);
}
else
{
...
...
@@ -855,7 +867,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.3">JVMS
* 4.7.3</a>
*/
private
static
void
dumpCodeAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpCodeAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
builder
.
add
(
"max_stack: "
,
parser
.
u2
());
builder
.
add
(
"max_locals: "
,
parser
.
u2
());
int
codeLength
=
parser
.
u4
();
...
...
@@ -909,8 +922,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html#jvms-6.5">JVMS
* 6.5</a>
*/
private
static
void
dumpInstructions
(
final
int
codeLength
,
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpInstructions
(
final
int
codeLength
,
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
bytecodeOffset
=
0
;
// Number of bytes parsed so far.
int
insnIndex
=
0
;
// Number of instructions parsed so far.
while
(
bytecodeOffset
<
codeLength
)
{
...
...
@@ -1419,7 +1432,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.2">JVMS
* 4.7.2</a>
*/
private
static
void
dumpVerificationTypeInfo
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpVerificationTypeInfo
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
tag
=
builder
.
add
(
"tag: "
,
parser
.
u1
());
if
(
tag
>
8
)
{
throw
new
IOException
(
"Unknown verification_type_info tag: "
+
tag
);
...
...
@@ -1440,7 +1454,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.5">JVMS
* 4.7.5</a>
*/
private
static
void
dumpExceptionsAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpExceptionsAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
exceptionCount
=
builder
.
add
(
"number_of_exceptions: "
,
parser
.
u2
());
for
(
int
i
=
0
;
i
<
exceptionCount
;
++
i
)
{
builder
.
addCpInfo
(
"exception_index: "
,
parser
.
u2
());
...
...
@@ -1456,7 +1471,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.6">JVMS
* 4.7.6</a>
*/
private
static
void
dumpInnerClassesAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpInnerClassesAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
classCount
=
builder
.
add
(
"number_of_classes: "
,
parser
.
u2
());
for
(
int
i
=
0
;
i
<
classCount
;
++
i
)
{
builder
.
addCpInfo
(
"inner_class_info_index: "
,
parser
.
u2
());
...
...
@@ -1500,7 +1516,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.9">JVMS
* 4.7.9</a>
*/
private
static
void
dumpSignatureAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpSignatureAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
builder
.
addCpInfo
(
"signature_index: "
,
parser
.
u2
());
}
...
...
@@ -1513,7 +1530,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.10">JVMS
* 4.7.10</a>
*/
private
static
void
dumpSourceFileAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpSourceFileAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
builder
.
addCpInfo
(
"sourcefile_index: "
,
parser
.
u2
());
}
...
...
@@ -1527,8 +1545,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.11">JVMS
* 4.7.11</a>
*/
private
static
void
dumpSourceDebugAttribute
(
final
int
attributeLength
,
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpSourceDebugAttribute
(
final
int
attributeLength
,
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
byte
[]
attributeData
=
parser
.
bytes
(
attributeLength
);
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
attributeData
.
length
;
++
i
)
{
...
...
@@ -1585,8 +1603,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.14">JVMS
* 4.7.14</a>
*/
private
static
void
dumpLocalVariableTypeTableAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpLocalVariableTypeTableAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
localVariableCount
=
builder
.
add
(
"local_variable_type_table_length: "
,
parser
.
u2
());
for
(
int
i
=
0
;
i
<
localVariableCount
;
++
i
)
{
int
startPc
=
builder
.
addInsnIndex
(
"start_pc: "
,
parser
.
u2
());
...
...
@@ -1616,8 +1634,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16">JVMS
* 4.7.16</a>
*/
private
static
void
dumpRuntimeVisibleAnnotationsAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpRuntimeVisibleAnnotationsAttribute
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
int
annotationCount
=
builder
.
add
(
"num_annotations: "
,
parser
.
u2
());
for
(
int
i
=
0
;
i
<
annotationCount
;
++
i
)
{
dumpAnnotation
(
parser
,
builder
);
...
...
@@ -1633,7 +1651,8 @@ class ClassDump {
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16">JVMS
* 4.7.16</a>
*/
private
static
void
dumpAnnotation
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
private
static
void
dumpAnnotation
(
final
Parser
parser
,
final
Builder
builder
)
throws
IOException
{
builder
.
addCpInfo
(
"type_index: "
,
parser
.
u2
());
int
elementValuePairCount
=
builder
.
add
(
"num_element_value_pairs: "
,
parser
.
u2
());
for
(
int
i
=
0
;
i
<
elementValuePairCount
;
++
i
)
{
...
...
@@ -1652,7 +1671,8 @@ class ClassDump {
* href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1">JVMS
* 4.7.16.1</a>
*/