forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request onlyliuxin#30 from chaoswang/master
更新四次作业博客
- Loading branch information
Showing
31 changed files
with
1,521 additions
and
37 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,2 +1,12 @@ | ||
CPU、内存、硬盘、指令以及他们之间的关系 | ||
https://zhuanlan.zhihu.com/p/25442061 | ||
第一次作业博客: | ||
CPU、内存、硬盘、指令以及他们之间的关系 | ||
https://zhuanlan.zhihu.com/p/25442061 | ||
第二次作业博客: | ||
为什么32位处理器只能配4G内存 | ||
https://zhuanlan.zhihu.com/p/26174778 | ||
第三次作业博客: | ||
报文和帧 | ||
https://zhuanlan.zhihu.com/p/26175504 | ||
第四次作业博客: | ||
依赖注入通俗解释 | ||
https://zhuanlan.zhihu.com/p/26176550 |
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,63 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.github.chaoswang</groupId> | ||
<artifactId>coding2017</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>coding2017</name> | ||
<description>coding2017</description> | ||
<build> | ||
<sourceDirectory>coding2017/group06/263050006/src/main/java</sourceDirectory> | ||
<testSourceDirectory>coding2017/group06/263050006/src/test/java</testSourceDirectory> | ||
<resources> | ||
<resource> | ||
<directory>coding2017/group06/263050006/src/main/java</directory> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.5</version> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.5</version> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/jdom/jdom --> | ||
<dependency> | ||
<groupId>jdom</groupId> | ||
<artifactId>jdom</artifactId> | ||
<version>1.1</version> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
</project> |
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
24 changes: 0 additions & 24 deletions
24
group06/263050006/src/main/java/com/github/chaoswang/learning/java/jvm/ClassFileLoader.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...06/263050006/src/main/java/com/github/chaoswang/learning/java/jvm/attr/AttributeInfo.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,19 @@ | ||
package com.github.chaoswang.learning.java.jvm.attr; | ||
|
||
public abstract class AttributeInfo { | ||
public static final String CODE = "Code"; | ||
public static final String CONST_VALUE = "ConstantValue"; | ||
public static final String EXCEPTIONS = "Exceptions"; | ||
public static final String LINE_NUM_TABLE = "LineNumberTable"; | ||
public static final String LOCAL_VAR_TABLE = "LocalVariableTable"; | ||
public static final String STACK_MAP_TABLE = "StackMapTable"; | ||
int attrNameIndex; | ||
int attrLen; | ||
|
||
public AttributeInfo(int attrNameIndex, int attrLen) { | ||
|
||
this.attrNameIndex = attrNameIndex; | ||
this.attrLen = attrLen; | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
group06/263050006/src/main/java/com/github/chaoswang/learning/java/jvm/attr/CodeAttr.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,50 @@ | ||
package com.github.chaoswang.learning.java.jvm.attr; | ||
|
||
import com.github.chaoswang.learning.java.jvm.clz.ClassFile; | ||
import com.github.chaoswang.learning.java.jvm.loader.ByteCodeIterator; | ||
|
||
public class CodeAttr extends AttributeInfo { | ||
private int maxStack ; | ||
private int maxLocals ; | ||
private int codeLen ; | ||
private String code; | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
//private ByteCodeCommand[] cmds ; | ||
//public ByteCodeCommand[] getCmds() { | ||
// return cmds; | ||
//} | ||
private LineNumberTable lineNumTable; | ||
private LocalVariableTable localVarTable; | ||
private StackMapTable stackMapTable; | ||
|
||
public CodeAttr(int attrNameIndex, int attrLen, int maxStack, int maxLocals, int codeLen,String code /*ByteCodeCommand[] cmds*/) { | ||
super(attrNameIndex, attrLen); | ||
this.maxStack = maxStack; | ||
this.maxLocals = maxLocals; | ||
this.codeLen = codeLen; | ||
this.code = code; | ||
//this.cmds = cmds; | ||
} | ||
|
||
public void setLineNumberTable(LineNumberTable t) { | ||
this.lineNumTable = t; | ||
} | ||
|
||
public void setLocalVariableTable(LocalVariableTable t) { | ||
this.localVarTable = t; | ||
} | ||
|
||
public static CodeAttr parse(ClassFile clzFile, ByteCodeIterator iter){ | ||
|
||
|
||
return null; | ||
} | ||
private void setStackMapTable(StackMapTable t) { | ||
this.stackMapTable = t; | ||
|
||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
.../263050006/src/main/java/com/github/chaoswang/learning/java/jvm/attr/LineNumberTable.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,45 @@ | ||
package com.github.chaoswang.learning.java.jvm.attr; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.github.chaoswang.learning.java.jvm.loader.ByteCodeIterator; | ||
|
||
public class LineNumberTable extends AttributeInfo { | ||
List<LineNumberItem> items = new ArrayList<LineNumberItem>(); | ||
|
||
private static class LineNumberItem { | ||
int startPC; | ||
int lineNum; | ||
|
||
public int getStartPC() { | ||
return startPC; | ||
} | ||
|
||
public void setStartPC(int startPC) { | ||
this.startPC = startPC; | ||
} | ||
|
||
public int getLineNum() { | ||
return lineNum; | ||
} | ||
|
||
public void setLineNum(int lineNum) { | ||
this.lineNum = lineNum; | ||
} | ||
} | ||
|
||
public void addLineNumberItem(LineNumberItem item) { | ||
this.items.add(item); | ||
} | ||
|
||
public LineNumberTable(int attrNameIndex, int attrLen) { | ||
super(attrNameIndex, attrLen); | ||
|
||
} | ||
|
||
public static LineNumberTable parse(ByteCodeIterator iter) { | ||
|
||
return null; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...63050006/src/main/java/com/github/chaoswang/learning/java/jvm/attr/LocalVariableItem.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,49 @@ | ||
package com.github.chaoswang.learning.java.jvm.attr; | ||
|
||
public class LocalVariableItem { | ||
private int startPC; | ||
private int length; | ||
private int nameIndex; | ||
private int descIndex; | ||
private int index; | ||
|
||
public int getStartPC() { | ||
return startPC; | ||
} | ||
|
||
public void setStartPC(int startPC) { | ||
this.startPC = startPC; | ||
} | ||
|
||
public int getLength() { | ||
return length; | ||
} | ||
|
||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
|
||
public int getNameIndex() { | ||
return nameIndex; | ||
} | ||
|
||
public void setNameIndex(int nameIndex) { | ||
this.nameIndex = nameIndex; | ||
} | ||
|
||
public int getDescIndex() { | ||
return descIndex; | ||
} | ||
|
||
public void setDescIndex(int descIndex) { | ||
this.descIndex = descIndex; | ||
} | ||
|
||
public int getIndex() { | ||
return index; | ||
} | ||
|
||
public void setIndex(int index) { | ||
this.index = index; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...3050006/src/main/java/com/github/chaoswang/learning/java/jvm/attr/LocalVariableTable.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 @@ | ||
package com.github.chaoswang.learning.java.jvm.attr; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.github.chaoswang.learning.java.jvm.loader.ByteCodeIterator; | ||
|
||
public class LocalVariableTable extends AttributeInfo{ | ||
|
||
List<LocalVariableItem> items = new ArrayList<LocalVariableItem>(); | ||
|
||
public LocalVariableTable(int attrNameIndex, int attrLen) { | ||
super(attrNameIndex, attrLen); | ||
} | ||
|
||
public static LocalVariableTable parse(ByteCodeIterator iter){ | ||
|
||
return null; | ||
} | ||
private void addLocalVariableItem(LocalVariableItem item) { | ||
this.items.add(item); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...06/263050006/src/main/java/com/github/chaoswang/learning/java/jvm/attr/StackMapTable.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,29 @@ | ||
package com.github.chaoswang.learning.java.jvm.attr; | ||
|
||
import com.github.chaoswang.learning.java.jvm.loader.ByteCodeIterator; | ||
|
||
public class StackMapTable extends AttributeInfo{ | ||
|
||
private String originalCode; | ||
|
||
public StackMapTable(int attrNameIndex, int attrLen) { | ||
super(attrNameIndex, attrLen); | ||
} | ||
|
||
public static StackMapTable parse(ByteCodeIterator iter){ | ||
int index = iter.nextU2ToInt(); | ||
int len = iter.nextU4ToInt(); | ||
StackMapTable t = new StackMapTable(index,len); | ||
|
||
//后面的StackMapTable太过复杂, 不再处理, 只把原始的代码读进来保存 | ||
String code = iter.nextUxToHexString(len); | ||
t.setOriginalCode(code); | ||
|
||
return t; | ||
} | ||
|
||
private void setOriginalCode(String code) { | ||
this.originalCode = code; | ||
|
||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
group06/263050006/src/main/java/com/github/chaoswang/learning/java/jvm/clz/AccessFlag.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,26 @@ | ||
package com.github.chaoswang.learning.java.jvm.clz; | ||
|
||
public class AccessFlag { | ||
private int flagValue; | ||
|
||
public AccessFlag(int value) { | ||
this.flagValue = value; | ||
} | ||
|
||
public int getFlagValue() { | ||
return flagValue; | ||
} | ||
|
||
public void setFlagValue(int flag) { | ||
this.flagValue = flag; | ||
} | ||
|
||
public boolean isPublicClass() { | ||
return (this.flagValue & 0x0001) != 0; | ||
} | ||
|
||
public boolean isFinalClass() { | ||
return (this.flagValue & 0x0010) != 0; | ||
} | ||
|
||
} |
Oops, something went wrong.