-
Notifications
You must be signed in to change notification settings - Fork 641
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
龚启盼
committed
Apr 11, 2017
1 parent
8afbe08
commit a260cd7
Showing
6 changed files
with
128 additions
and
27 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
31 changes: 31 additions & 0 deletions
31
group11/252308879/mini-jvm/src/main/java/com/pan/jvm/EmployeeV1.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,31 @@ | ||
package com.pan.jvm; | ||
|
||
public class EmployeeV1 { | ||
|
||
|
||
private String name; | ||
private int age; | ||
|
||
public EmployeeV1(String name, int age) { | ||
this.name = name; | ||
this.age = age; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
|
||
public void sayHello() { | ||
System.out.println("Hello , this is class Employee "); | ||
} | ||
|
||
public static void main(String[] args) { | ||
EmployeeV1 p = new EmployeeV1("Andy", 29); | ||
p.sayHello(); | ||
|
||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
group11/252308879/mini-jvm/src/test/java/com/pan/alg/LRUPageFrameTest.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,34 @@ | ||
package com.pan.alg; | ||
|
||
import org.junit.Assert; | ||
|
||
import org.junit.Test; | ||
|
||
|
||
public class LRUPageFrameTest { | ||
|
||
@Test | ||
public void testAccess() { | ||
LRUPageFrame frame = new LRUPageFrame(3); | ||
frame.access(7); | ||
frame.access(0); | ||
frame.access(1); | ||
Assert.assertEquals("1,0,7", frame.toString()); | ||
frame.access(2); | ||
Assert.assertEquals("2,1,0", frame.toString()); | ||
frame.access(0); | ||
Assert.assertEquals("0,2,1", frame.toString()); | ||
frame.access(0); | ||
Assert.assertEquals("0,2,1", frame.toString()); | ||
frame.access(3); | ||
Assert.assertEquals("3,0,2", frame.toString()); | ||
frame.access(0); | ||
Assert.assertEquals("0,3,2", frame.toString()); | ||
frame.access(4); | ||
Assert.assertEquals("4,0,3", frame.toString()); | ||
frame.access(5); | ||
Assert.assertEquals("5,4,0", frame.toString()); | ||
|
||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
group11/252308879/mini-jvm/src/test/java/com/pan/jvm/EmployeeV1.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,31 @@ | ||
package com.pan.jvm; | ||
|
||
public class EmployeeV1 { | ||
|
||
|
||
private String name; | ||
private int age; | ||
|
||
public EmployeeV1(String name, int age) { | ||
this.name = name; | ||
this.age = age; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
|
||
public void sayHello() { | ||
System.out.println("Hello , this is class Employee "); | ||
} | ||
|
||
public static void main(String[] args) { | ||
EmployeeV1 p = new EmployeeV1("Andy", 29); | ||
p.sayHello(); | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
group11/252308879/mini-jvm/src/test/java/com/pan/jvm/TestReadCFBB.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 |
---|---|---|
@@ -1,10 +1,41 @@ | ||
package com.pan.jvm; | ||
|
||
import com.pan.jvm.loader.ClassFileLoader; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* 用于测试第一次JVM作业,读取.class作业 和 魔幻数字 | ||
*/ | ||
public class TestReadCFBB { | ||
|
||
@Test | ||
public void testClassPath(){ | ||
ClassFileLoader classFileLoader = new ClassFileLoader(); | ||
String path = ClassFileLoader.class.getClassLoader().getResource("").getPath(); | ||
path = path.replace("test-classes", "classes"); | ||
classFileLoader.addClassPath(path); | ||
classFileLoader.addClassPath("d://tmp"); | ||
|
||
String clzPath = classFileLoader.getClassPath(); | ||
System.out.println(clzPath); | ||
} | ||
|
||
|
||
|
||
@Test | ||
public void testReadCFBB() throws IOException { | ||
|
||
ClassFileLoader classFileLoader = new ClassFileLoader(); | ||
String path = ClassFileLoader.class.getClassLoader().getResource("").getPath(); | ||
path = path.replace("test-classes", "classes"); | ||
classFileLoader.addClassPath(path); | ||
byte[] bytes = classFileLoader.readBinaryCode("com.pan.jvm.loader.ClassFileLoader"); | ||
for (byte b : bytes) { | ||
String toHexString = Integer.toHexString(b & 0xFF).toUpperCase(); | ||
System.out.print(toHexString + " "); | ||
} | ||
} | ||
|
||
} |