-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not generate stack map frames for Java 5 bytecode
Fixes #55
- Loading branch information
Showing
7 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
end-to-end-tests/src/test/java/net/orfjackal/retrolambda/test/Java5BytecodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net> | ||
// This software is released under the Apache License 2.0. | ||
// The license text is at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package net.orfjackal.retrolambda.test; | ||
|
||
import com.google.common.io.CharStreams; | ||
import org.apache.commons.lang.SystemUtils; | ||
import org.junit.Test; | ||
|
||
import java.io.*; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
public class Java5BytecodeTest { | ||
|
||
@Test | ||
public void does_not_generate_stack_map_tables_for_Java_5() throws IOException { | ||
String javapOutput = javap(Dummy.class); | ||
|
||
if (SystemUtils.isJavaVersionAtLeast(1.6f)) { | ||
assertThat(javapOutput, containsString("StackMap")); | ||
} else { | ||
assertThat(javapOutput, not(containsString("StackMap"))); | ||
} | ||
} | ||
|
||
private static String javap(Class<?> aClass) throws IOException { | ||
Process process = new ProcessBuilder() | ||
.directory(TestEnv.testClassesDir) | ||
.command("javap", "-v", "-p", aClass.getName()) | ||
.redirectErrorStream(true) | ||
.start(); | ||
return CharStreams.toString(new InputStreamReader(process.getInputStream())); | ||
} | ||
|
||
|
||
public static class Dummy { | ||
public Dummy() { | ||
// cause this method to have a stack map table | ||
for (int i = 0; i < 3; i++) { | ||
System.out.println(i); | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
end-to-end-tests/src/test/java/net/orfjackal/retrolambda/test/TestEnv.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net> | ||
// This software is released under the Apache License 2.0. | ||
// The license text is at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package net.orfjackal.retrolambda.test; | ||
|
||
import java.io.*; | ||
import java.util.Properties; | ||
|
||
public class TestEnv { | ||
|
||
public static final File testClassesDir; | ||
|
||
static { | ||
Properties p = new Properties(); | ||
try (InputStream in = TestEnv.class.getResourceAsStream("/testing.properties")) { | ||
p.load(in); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
testClassesDir = new File(p.getProperty("testClassesDir")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
testClassesDir=${project.build.testOutputDirectory} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters