-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
67 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
.gradle | ||
build | ||
|
||
.DS_Store | ||
*.swp | ||
|
||
/java | ||
.idea | ||
.gradle | ||
|
||
.idea | ||
build | ||
out | ||
myjre | ||
/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,37 @@ | ||
package classfile | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestJava8HW(t *testing.T) { | ||
bytes, err := ioutil.ReadFile("../test/testdata/java8/HelloWorld.class") | ||
require.NoError(t, err) | ||
|
||
cf, err := Parse(bytes) | ||
require.NoError(t, err) | ||
require.Equal(t, uint16(52), cf.MajorVersion) | ||
require.Equal(t, uint16(0), cf.MinorVersion) | ||
require.Equal(t, 34, len(cf.ConstantPool)) | ||
require.Equal(t, uint16(0x21), cf.AccessFlags) | ||
require.Equal(t, "HelloWorld", cf.GetThisClassName()) | ||
require.Equal(t, "java/lang/Object", cf.GetSuperClassName()) | ||
require.Equal(t, []string{}, cf.GetInterfaceNames()) | ||
require.Equal(t, 0, len(cf.Fields)) | ||
require.Equal(t, 2, len(cf.Methods)) | ||
require.Equal(t, 1, len(cf.AttributeTable.attributes)) | ||
require.Equal(t, "HelloWorld.java", cf.GetUTF8(cf.GetSourceFileIndex())) | ||
} | ||
|
||
func TestJava13HW(t *testing.T) { | ||
bytes, err := ioutil.ReadFile("../test/testdata/java13/HelloWorld.class") | ||
require.NoError(t, err) | ||
|
||
cf, err := Parse(bytes) | ||
require.NoError(t, err) | ||
require.Equal(t, uint16(57), cf.MajorVersion) | ||
require.Equal(t, uint16(0), cf.MinorVersion) | ||
} |
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,7 @@ | ||
package hello; | ||
|
||
class HelloWorld { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, world!"); | ||
} | ||
} |
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,3 @@ | ||
module hello.modules { | ||
exports hello; | ||
} |
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,14 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
alias javac='~/.sdkman/candidates/java/13.0.0-open/bin/javac' | ||
alias jlink='~/.sdkman/candidates/java/13.0.0-open/bin/jlink' | ||
|
||
javac -version | grep 'javac 13' | ||
jlink --version | grep 13 | ||
|
||
OUT=myjre | ||
rm -rf $OUT | ||
javac --module-source-path src -d out -m hello.modules | ||
jlink --module-path out --add-modules hello.modules,java.base --output $OUT | ||
./$OUT/bin/java -m hello.modules/hello.HelloWorld |
Binary file not shown.
Binary file not shown.
Binary file not shown.