Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jamie Mansfield
asm
Commits
2056c3b8
Commit
2056c3b8
authored
Jun 13, 2018
by
Jason Zaugg
Browse files
Consistently assert that instructions are not already owned
parent
bc33e850
Changes
2
Hide whitespace changes
Inline
Side-by-side
asm-tree/src/main/java/org/objectweb/asm/tree/InsnList.java
View file @
2056c3b8
...
...
@@ -190,6 +190,7 @@ public class InsnList {
* @param newInsnNode another instruction, <i>which must not belong to any {@link InsnList}</i>.
*/
public
void
set
(
final
AbstractInsnNode
oldInsnNode
,
final
AbstractInsnNode
newInsnNode
)
{
ensureNotOwned
(
newInsnNode
);
AbstractInsnNode
nextInsn
=
oldInsnNode
.
nextInsn
;
newInsnNode
.
nextInsn
=
nextInsn
;
if
(
nextInsn
!=
null
)
{
...
...
@@ -266,6 +267,7 @@ public class InsnList {
* @param insnNode an instruction, <i>which must not belong to any {@link InsnList}</i>.
*/
public
void
insert
(
final
AbstractInsnNode
insnNode
)
{
ensureNotOwned
(
insnNode
);
++
size
;
if
(
firstInsn
==
null
)
{
firstInsn
=
insnNode
;
...
...
@@ -311,6 +313,7 @@ public class InsnList {
* InsnList}</i>.
*/
public
void
insert
(
final
AbstractInsnNode
previousInsn
,
final
AbstractInsnNode
insnNode
)
{
ensureNotOwned
(
insnNode
);
++
size
;
AbstractInsnNode
nextInsn
=
previousInsn
.
nextInsn
;
if
(
nextInsn
==
null
)
{
...
...
@@ -361,6 +364,7 @@ public class InsnList {
* InsnList}</i>.
*/
public
void
insertBefore
(
final
AbstractInsnNode
nextInsn
,
final
AbstractInsnNode
insnNode
)
{
ensureNotOwned
(
insnNode
);
++
size
;
AbstractInsnNode
previousInsn
=
nextInsn
.
previousInsn
;
if
(
previousInsn
==
null
)
{
...
...
asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java
View file @
2056c3b8
...
...
@@ -752,7 +752,14 @@ public class InsnListTest {
@Test
public
void
testAddNodeAssociatedWithAnotherList
()
{
InsnNode
insnNode
=
new
InsnNode
(
0
);
assertThrows
(
IllegalArgumentException
.
class
,
()
->
list3Unchecked
.
add
(
insn1
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
list3Unchecked
.
insert
(
insn1
));
list3Unchecked
.
insert
(
insnNode
);
assertThrows
(
IllegalArgumentException
.
class
,
()
->
list3Unchecked
.
insert
(
insnNode
,
insn1
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
list3Unchecked
.
insertBefore
(
insnNode
,
insn1
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
list3Unchecked
.
set
(
insnNode
,
insn1
));
assertThrows
(
IllegalArgumentException
.
class
,
()
->
list3Unchecked
.
set
(
insnNode
,
insn1
));
}
/** An InsnList which checks that its methods are properly used. */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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