Skip to content
This repository was archived by the owner on Feb 17, 2022. It is now read-only.

Commit fda7563

Browse files
committed
Update README.md
1 parent 72bb056 commit fda7563

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ aClass.getMethods().add(m);
3030
##### Bytecode
3131
Finally, bytecode! In Java, bytecode goes into a thing called a *code attribute*, which then goes into the method. Here's a sample:
3232
```java
33-
List<JvmInstructionImpl> instructions = Arrays.asList(
33+
CodeAttribute code = new CodeAttribute(new UTF8Entry(aClass.getConstantPool(), "Code"), 5, 2,
3434
JvmInstructions.ALOAD.create(0),
3535
JvmInstructions.DUP.create()
3636
);
37-
CodeAttribute code = new CodeAttribute(new UTF8Entry(aClass.getConstantPool(), "Code"), 5, 2, instructions);
3837
m.getAttributes().add(code);
3938
```
4039
The code attribute has 4 arguments: a `UTF8Entry` pointing to the value `Code` (this is very important!), the max stack size, the max local variable size, and a list of bytecode instructions. In this case the instructions are `aload 0, dup`
@@ -45,5 +44,5 @@ What's the point of having a Java class if you can't write it? The `JavaClass` h
4544
## Todo
4645
- Add the rest of the bytecode instructions
4746
- Add more attributes
48-
- Add interface, field, and attribute capabilities to classes
47+
- Add interface and field capabilities to classes
4948
- Add exception tables to the code attribute

0 commit comments

Comments
 (0)