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
asm
asm
Commits
3e3cfd5a
Commit
3e3cfd5a
authored
Dec 24, 2020
by
Remi Forax
Browse files
Merge branch 'master' into 'test-should-work-with-enable-preview'
# Conflicts: # asm/src/main/java/org/objectweb/asm/ClassReader.java
parents
fbc8b8d6
eaa1b423
Pipeline
#10450
passed with stage
in 8 minutes and 43 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
3e3cfd5a
image
:
gradle:6.
3
-jdk
8
image
:
gradle:6.
7.1
-jdk
11
variables
:
# Set the location of the dependency cache to a local directory, so that it
...
...
@@ -18,4 +18,4 @@ build:
-
$GRADLE test jacocoTestCoverageVerification
-
if [ $NEXUS_USER_NAME ]; then $GRADLE publish; fi
-
if [ !$NEXUS_USER_NAME ]; then $GRADLE publishToMavenLocal; fi
-
'
$GRADLE
sonarqube
-Dsonar.host.url=$SONAR'
-
'
$GRADLE
jacocoTestReport
sonarqube
-Dsonar.host.url=$SONAR'
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java
View file @
3e3cfd5a
...
...
@@ -316,7 +316,7 @@ public class Analyzer<V extends Value> implements Opcodes {
throws
AnalyzerException
{
method
.
maxLocals
=
computeMaxLocals
(
method
);
method
.
maxStack
=
-
1
;
Frame
<
V
>[]
frames
=
analyze
(
owner
,
method
);
analyze
(
owner
,
method
);
method
.
maxStack
=
computeMaxStack
(
frames
);
return
frames
;
}
...
...
asm-tree/src/test/java/org/objectweb/asm/tree/InsnNodeTest.java
View file @
3e3cfd5a
...
...
@@ -45,6 +45,6 @@ public class InsnNodeTest extends AsmTest {
InsnNode
insnNode
=
new
InsnNode
(
Opcodes
.
ACONST_NULL
);
assertEquals
(
AbstractInsnNode
.
INSN
,
insnNode
.
getType
());
assertEquals
(
insnNode
.
getOpcode
(),
Opcodes
.
ACONST_NULL
);
assertEquals
(
Opcodes
.
ACONST_NULL
,
insnNode
.
getOpcode
()
);
}
}
asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java
View file @
3e3cfd5a
...
...
@@ -106,6 +106,7 @@ public class ASMifier extends Printer {
classVersions
.
put
(
Opcodes
.
V14
,
"V14"
);
classVersions
.
put
(
Opcodes
.
V15
,
"V15"
);
classVersions
.
put
(
Opcodes
.
V16
,
"V16"
);
classVersions
.
put
(
Opcodes
.
V17
,
"V17"
);
CLASS_VERSIONS
=
Collections
.
unmodifiableMap
(
classVersions
);
}
...
...
@@ -628,9 +629,7 @@ public class ASMifier extends Printer {
@Override
public
void
visitRecordComponentEnd
()
{
stringBuilder
.
setLength
(
0
);
stringBuilder
.
append
(
name
).
append
(
VISIT_END
);
text
.
add
(
stringBuilder
.
toString
());
visitMemberEnd
();
}
// -----------------------------------------------------------------------------------------------
...
...
@@ -655,9 +654,7 @@ public class ASMifier extends Printer {
@Override
public
void
visitFieldEnd
()
{
stringBuilder
.
setLength
(
0
);
stringBuilder
.
append
(
name
).
append
(
VISIT_END
);
text
.
add
(
stringBuilder
.
toString
());
visitMemberEnd
();
}
// -----------------------------------------------------------------------------------------------
...
...
@@ -1130,9 +1127,7 @@ public class ASMifier extends Printer {
@Override
public
void
visitMethodEnd
()
{
stringBuilder
.
setLength
(
0
);
stringBuilder
.
append
(
name
).
append
(
VISIT_END
);
text
.
add
(
stringBuilder
.
toString
());
visitMemberEnd
();
}
// -----------------------------------------------------------------------------------------------
...
...
@@ -1242,6 +1237,13 @@ public class ASMifier extends Printer {
text
.
add
(
stringBuilder
.
toString
());
}
/** Visits the end of a field, record component or method. */
private
void
visitMemberEnd
()
{
stringBuilder
.
setLength
(
0
);
stringBuilder
.
append
(
name
).
append
(
VISIT_END
);
text
.
add
(
stringBuilder
.
toString
());
}
// -----------------------------------------------------------------------------------------------
// Utility methods
// -----------------------------------------------------------------------------------------------
...
...
asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java
View file @
3e3cfd5a
...
...
@@ -999,8 +999,6 @@ public class CheckClassAdapter extends ClassVisitor {
// Can't fix PMD warning for 1.5 compatibility.
try
(
InputStream
inputStream
=
new
FileInputStream
(
args
[
0
]))
{
// NOPMD(AvoidFileStream)
classReader
=
new
ClassReader
(
inputStream
);
}
catch
(
IOException
ioe
)
{
throw
ioe
;
}
}
else
{
classReader
=
new
ClassReader
(
args
[
0
]);
...
...
asm-util/src/main/java/org/objectweb/asm/util/Printer.java
View file @
3e3cfd5a
...
...
@@ -1310,8 +1310,6 @@ public abstract class Printer {
// Can't fix PMD warning for 1.5 compatibility.
try
(
InputStream
inputStream
=
new
FileInputStream
(
className
))
{
// NOPMD(AvoidFileStream)
new
ClassReader
(
inputStream
).
accept
(
traceClassVisitor
,
parsingOptions
);
}
catch
(
IOException
ioe
)
{
throw
ioe
;
}
}
else
{
new
ClassReader
(
className
).
accept
(
traceClassVisitor
,
parsingOptions
);
...
...
asm/src/main/java/org/objectweb/asm/ClassReader.java
View file @
3e3cfd5a
...
...
@@ -191,7 +191,7 @@ public class ClassReader {
this
.
b
=
classFileBuffer
;
// Check the class' major_version. This field is after the magic and minor_version fields, which
// use 4 and 2 bytes respectively.
if
(
checkClassVersion
&&
readShort
(
classFileOffset
+
6
)
>
Opcodes
.
V1
6
)
{
if
(
checkClassVersion
&&
readShort
(
classFileOffset
+
6
)
>
Opcodes
.
V1
7
)
{
throw
new
IllegalArgumentException
(
"Unsupported class file major version "
+
readShort
(
classFileOffset
+
6
));
}
...
...
@@ -3458,17 +3458,17 @@ public class ClassReader {
currentAttributeOffset
+=
6
;
if
(
Constants
.
BOOTSTRAP_METHODS
.
equals
(
attributeName
))
{
// Read the num_bootstrap_methods field and create an array of this size.
int
[]
currentBootstrapMethodOffsets
=
new
int
[
readUnsignedShort
(
currentAttributeOffset
)];
int
[]
result
=
new
int
[
readUnsignedShort
(
currentAttributeOffset
)];
// Compute and store the offset of each 'bootstrap_methods' array field entry.
int
currentBootstrapMethodOffset
=
currentAttributeOffset
+
2
;
for
(
int
j
=
0
;
j
<
currentBootstrapMethodOffsets
.
length
;
++
j
)
{
currentBootstrapMethodOffsets
[
j
]
=
currentBootstrapMethodOffset
;
for
(
int
j
=
0
;
j
<
result
.
length
;
++
j
)
{
result
[
j
]
=
currentBootstrapMethodOffset
;
// Skip the bootstrap_method_ref and num_bootstrap_arguments fields (2 bytes each),
// as well as the bootstrap_arguments array field (of size num_bootstrap_arguments * 2).
currentBootstrapMethodOffset
+=
4
+
readUnsignedShort
(
currentBootstrapMethodOffset
+
2
)
*
2
;
}
return
currentBootstrapMethodOffsets
;
return
result
;
}
currentAttributeOffset
+=
attributeLength
;
}
...
...
asm/src/main/java/org/objectweb/asm/Opcodes.java
View file @
3e3cfd5a
...
...
@@ -133,7 +133,7 @@ public interface Opcodes {
* <pre>
* public class StuffVisitor {
* @Deprecated public void visitOldStuff(int arg, ...) {
* visitNewStuf(arg | SOURCE_DEPRECATED, ...);
* visitNewStuf
f
(arg | SOURCE_DEPRECATED, ...);
* }
* public void visitNewStuff(int argAndSource...) {
* if ((argAndSource & SOURCE_DEPRECATED) == 0) {
...
...
@@ -155,7 +155,7 @@ public interface Opcodes {
* <p>and there are two cases:
*
* <ul>
* <li>call visitOldSuff: in the call to super.visitOldStuff, the source is set to
* <li>call visitOldS
t
uff: in the call to super.visitOldStuff, the source is set to
* SOURCE_DEPRECATED and visitNewStuff is called. Here 'do stuff' is run because the source
* was previously set to SOURCE_DEPRECATED, and execution eventually returns to
* UserStuffVisitor.visitOldStuff, where 'do user stuff' is run.
...
...
@@ -282,6 +282,7 @@ public interface Opcodes {
int
V14
=
0
<<
16
|
58
;
int
V15
=
0
<<
16
|
59
;
int
V16
=
0
<<
16
|
60
;
int
V17
=
0
<<
16
|
61
;
/**
* Version flag indicating that the class is using 'preview' features.
...
...
asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java
View file @
3e3cfd5a
...
...
@@ -358,7 +358,7 @@ public class ClassVisitorTest extends AsmTest {
public
ModuleVisitor
visitModule
(
final
String
name
,
final
int
access
,
final
String
version
)
{
return
new
ModuleVisitor
(
api
,
super
.
visitModule
(
name
,
access
,
version
))
{};
}
}
;
}
private
static
class
FieldAdapter
extends
FieldVisitor
{
...
...
asm/src/test/java/org/objectweb/asm/ConstantsTest.java
View file @
3e3cfd5a
...
...
@@ -217,8 +217,7 @@ public class ConstantsTest {
private
static
List
<
Field
>
getConstants
(
final
ConstantType
constantType
)
{
return
Stream
.
concat
(
Arrays
.
asList
(
Opcodes
.
class
.
getFields
()).
stream
(),
Arrays
.
asList
(
Constants
.
class
.
getFields
()).
stream
())
Arrays
.
stream
(
Opcodes
.
class
.
getFields
()),
Arrays
.
stream
(
Constants
.
class
.
getFields
()))
.
filter
(
field
->
getType
(
field
).
equals
(
constantType
))
.
collect
(
Collectors
.
toList
());
}
...
...
@@ -250,6 +249,7 @@ public class ConstantsTest {
case
"V14"
:
case
"V15"
:
case
"V16"
:
case
"V17"
:
return
ConstantType
.
CLASS_VERSION
;
case
"ACC_PUBLIC"
:
case
"ACC_PRIVATE"
:
...
...
build.gradle
View file @
3e3cfd5a
...
...
@@ -28,13 +28,13 @@
buildscript
{
repositories
{
mavenCentral
()
}
dependencies
{
classpath
'org.netbeans.tools:sigtest-maven-plugin:1.
1
'
}
dependencies
{
classpath
'org.netbeans.tools:sigtest-maven-plugin:1.
3
'
}
}
plugins
{
id
'biz.aQute.bnd.builder'
version
'5.2.0'
apply
false
}
plugins
{
id
'com.github.sherter.google-java-format'
version
'0.9'
apply
false
}
plugins
{
id
'me.champeau.gradle.jmh'
version
'0.5.
0
'
apply
false
}
plugins
{
id
'org.sonarqube'
version
'
2.8
'
apply
false
}
plugins
{
id
'me.champeau.gradle.jmh'
version
'0.5.
2
'
apply
false
}
plugins
{
id
'org.sonarqube'
version
'
3.0
'
apply
false
}
description
=
'ASM, a very small and fast Java bytecode manipulation framework'
...
...
@@ -82,8 +82,8 @@ project(':asm-commons') {
project
(
':asm-test'
)
{
description
=
"Utilities for testing ${parent.description}"
provides
=
[
'org.objectweb.asm.test'
]
depends
=
[
'org.junit.jupiter:junit-jupiter-api:5.
6.1
'
,
'org.junit.jupiter:junit-jupiter-params:5.
6.1
'
]
depends
=
[
'org.junit.jupiter:junit-jupiter-api:5.
7.0
'
,
'org.junit.jupiter:junit-jupiter-params:5.
7.0
'
]
}
project
(
':asm-tree'
)
{
...
...
@@ -153,7 +153,7 @@ project(':tools:bnd-module-plugin') {
description
=
"bnd plugin to build moduleinfo with ${rootProject.description}"
// TODO: this compiles asm twice (here and in :asm), find a way to avoid this.
sourceSets
.
main
.
java
.
srcDirs
+=
project
(
':asm'
).
sourceSets
.
main
.
java
.
srcDirs
depends
=
[
'biz.aQute.bnd:biz.aQute.bnd:
4.0
.0'
]
depends
=
[
'biz.aQute.bnd:biz.aQute.bnd:
5.2
.0'
]
}
project
(
':tools:retrofitter'
)
{
...
...
@@ -170,7 +170,7 @@ project(':tools:retrofitter') {
// and tested with :asm-test and JUnit.
subprojects
{
apply
plugin:
'com.github.sherter.google-java-format'
googleJavaFormat
.
toolVersion
=
'1.
7
'
googleJavaFormat
.
toolVersion
=
'1.
9
'
googleJavaFormat
.
exclude
'src/resources/java/**/*'
// Check the coding style with Checkstyle. Fail in case of error or warning.
...
...
@@ -188,9 +188,9 @@ subprojects {
dependencies
{
requires
.
each
{
projectName
->
api
project
(
projectName
)
}
depends
.
each
{
artifactName
->
api
artifactName
}
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.
6.1
'
,
'org.junit.jupiter:junit-jupiter-params:5.
6.1
'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.
6.1
'
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.
7.0
'
,
'org.junit.jupiter:junit-jupiter-params:5.
7.0
'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.
7.0
'
testImplementation
project
(
':asm-test'
)
}
...
...
@@ -209,7 +209,9 @@ subprojects {
// and uploaded to Maven with a POM, sources and Javadoc.
configure
(
subprojects
.
findAll
{
it
.
provides
})
{
// Code coverage configuration.
jacoco
.
toolVersion
=
'0.8.6'
jacocoTestReport
{
reports
{
xml
.
enabled
true
}
classDirectories
.
setFrom
(
sourceSets
.
main
.
output
.
classesDirs
)
}
jacocoTestCoverageVerification
{
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
3e3cfd5a
...
...
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-6.
3
-bin.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-6.
7.1
-bin.zip
tools/checkstyle.xml
View file @
3e3cfd5a
...
...
@@ -86,11 +86,9 @@
<module
name=
"JavadocMethod"
>
<property
name=
"scope"
value=
"public"
/>
<property
name=
"allowMissingParamTags"
value=
"true"
/>
<property
name=
"allowMissingThrowsTags"
value=
"true"
/>
<property
name=
"allowMissingReturnTag"
value=
"true"
/>
<property
name=
"allowedAnnotations"
value=
"Override,BeforeEach,Test,ParameterizedTest,Setup,Benchmark"
/>
<property
name=
"allowThrowsTagsForSubclasses"
value=
"true"
/>
</module>
<module
name=
"MethodName"
>
<property
name=
"format"
value=
"^[a-z][a-z0-9][a-zA-Z0-9_]*$"
/>
...
...
tools/pmd.xml
View file @
3e3cfd5a
...
...
@@ -38,8 +38,7 @@
<!-- Already covered with google-java-format. -->
<exclude
name=
"OneDeclarationPerLine"
/>
<!-- Actually not a best practice. -->
<exclude
name=
"PositionLiteralsFirstInCaseInsensitiveComparisons"
/>
<exclude
name=
"PositionLiteralsFirstInComparisons"
/>
<exclude
name=
"LiteralsFirstInComparisons"
/>
<!-- Already covered with Checkstyle 'MissingSwitchDefault' rule. -->
<exclude
name=
"SwitchStmtsShouldHaveDefault"
/>
<!-- Already covered with google-java-format. -->
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment