| org.objectweb.asm.commons.JSRInlinerAdapterUnitTest
JSRInlinerAdapterUnitTest | public class JSRInlinerAdapterUnitTest extends TestCase (Code) | | JsrInlinerTest
author: Eugene Kuleshov, Niko Matsakis, Eric Bruneton |
Inner Class :static class TestClassLoader extends ClassLoader | |
testBasic | public void testBasic()(Code) | | Tests a method which has the most basic try{}finally form
imaginable:
public void a() {
int a = 0;
try {
a++;
} finally {
a--;
}
}
|
testBasicLineNumberAndLocalVars | public void testBasicLineNumberAndLocalVars()(Code) | | Tests a method which has line numbers and local variable declarations.
public void a() {
1 int a = 0;
2 try {
3 a++;
4 } finally {
5 a--;
6 }
}
LV "a" from 1 to 6
|
testCommonCodeWhichMustBeDuplicated | public void testCommonCodeWhichMustBeDuplicated()(Code) | | This tests two subroutines, neither of which exit. Instead, they both
branch to a common set of code which returns from the method. This code
is not reachable except through these subroutines, and since they do not
invoke each other, it must be copied into both of them.
I don't believe this can be represented in Java.
|
testIfElseInFinally | public void testIfElseInFinally()(Code) | | Tests a method which has an if/else-if w/in the finally clause:
public void a() {
int a = 0;
try {
a++;
} finally {
if (a == 0)
a+=2;
else
a+=3;
}
}
|
testImplicitExit | public void testImplicitExit()(Code) | | This tests a subroutine which has no ret statement, but instead exits
implicitely by branching to code which is not part of the subroutine.
(Sadly, this is legal)
We structure this as a try/finally in a loop with a break in the finally.
The loop is not trivially infinite, so the RETURN statement is reachable
both from the JSR subroutine and from the main entry point.
public void a1() {
int a = 0;
while (null == null) {
try {
a += 1;
} finally {
a += 2;
break;
}
}
}
|
testImplicitExitInTryCatch | public void testImplicitExitInTryCatch()(Code) | | Tests a nested try/finally with implicit exit from one subroutine to the
other subroutine, and with a surrounding try/catch thrown in the mix.
Equivalent to the following java code:
void m(int b) {
try {
try {
return;
} finally {
while (b) {
try {
return;
} finally {
// NOTE --- this break avoids the second return above (weird)
if (b) break;
}
}
}
} catch (Exception e) {
b += 3;
return;
}
}
|
testImplicitExitToAnotherSubroutine | public void testImplicitExitToAnotherSubroutine()(Code) | | Tests a nested try/finally with implicit exit from one subroutine to the
other subroutine. Equivalent to the following java code:
void m(boolean b) {
try {
return;
} finally {
while (b) {
try {
return;
} finally {
// NOTE --- this break avoids the second return above (weird)
if (b) break;
}
}
}
}
This example is from the paper, "Subroutine Inlining and Bytecode
Abstraction to Simplify Static and Dynamic Analysis" by Cyrille Artho and
Armin Biere.
|
testInterleavedCode | public void testInterleavedCode()(Code) | | This tests a simple subroutine where the control flow jumps back and
forth between the subroutine and the caller.
This would not normally be produced by a java compiler.
|
testSimpleNestedFinally | public void testSimpleNestedFinally()(Code) | | Tests a simple nested finally:
public void a1() {
int a = 0;
try {
a += 1;
} finally {
try {
a += 2;
} finally {
a += 3;
}
}
}
|
testSubroutineWithNoRet | public void testSubroutineWithNoRet()(Code) | | This tests a subroutine which has no ret statement, but ends in a
"return" instead.
We structure this as a try/finally with a break in the finally. Because
the while loop is infinite, it's clear from the byte code that the only
path which reaches the RETURN instruction is through the subroutine.
public void a1() {
int a = 0;
while (true) {
try {
a += 1;
} finally {
a += 2;
break;
}
}
}
|
testSubroutineWithNoRet2 | public void testSubroutineWithNoRet2()(Code) | | This tests a subroutine which has no ret statement, but ends in a
"return" instead.
JSR L0
L0:
ASTORE 0
RETURN
|
|
|