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
Evgeny Mandrikov
asm
Commits
982da481
Commit
982da481
authored
Dec 22, 2020
by
Eric Bruneton
Browse files
Fix some code smells found with SonarQube.
parent
c90dd56f
Pipeline
#10426
passed with stage
in 8 minutes and 35 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/Analyzer.java
View file @
982da481
...
...
@@ -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 @
982da481
...
...
@@ -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 @
982da481
...
...
@@ -629,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
();
}
// -----------------------------------------------------------------------------------------------
...
...
@@ -656,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
();
}
// -----------------------------------------------------------------------------------------------
...
...
@@ -1131,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
();
}
// -----------------------------------------------------------------------------------------------
...
...
@@ -1243,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 @
982da481
...
...
@@ -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 @
982da481
...
...
@@ -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 @
982da481
...
...
@@ -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
[]
bootstrapMethodOffsets
=
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
<
bootstrapMethodOffsets
.
length
;
++
j
)
{
bootstrapMethodOffsets
[
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
bootstrapMethodOffsets
;
return
result
;
}
currentAttributeOffset
+=
attributeLength
;
}
...
...
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