mirror of
https://github.com/ParkerTenBroeck/ParkerTenBroeck.github.io.git
synced 2026-06-06 21:14:06 -04:00
added styles for gh md extensions, worked on generators post
This commit is contained in:
parent
bd7eaeec38
commit
d5fa5f0608
5 changed files with 193 additions and 36 deletions
|
|
@ -37,6 +37,7 @@ render_emoji = true
|
|||
bottom_footnotes = true
|
||||
github_alerts = true
|
||||
|
||||
# insert_anchor_links = "heading"
|
||||
|
||||
[markdown.highlighting]
|
||||
light_theme = "github-light-high-contrast"
|
||||
|
|
|
|||
|
|
@ -8,10 +8,70 @@ tags = ["java", "bytecode"]
|
|||
category = ["project"]
|
||||
+++
|
||||
|
||||
|
||||
With the release of Java 24 came the official Class-File API giving a stable and (relatively) ergonomic interface for reading, modifying, and writing java classes/bytecode at runtime with no external dependencies. Seeing this I decided to play around with it and see what fun I could have.
|
||||
|
||||
|
||||
|
||||
# Bytecode, Stack Machines, and Registers
|
||||
|
||||
Java (and other JVM languages) are compiled to a set of [bytecode instructions](https://en.wikipedia.org/wiki/List_of_JVM_bytecode_instructions).
|
||||
These instructions primarily operate on a stack (fifo) using 0-n operands from the top and pushing 0-1 values back onto the stack.
|
||||
|
||||
An example would be the `iadd` instruction which pops two integers off the stack and pushes the sum of them.
|
||||
|
||||
A more complex example would be something like `invokevirtual <methodref_index>` which calls a method on a class.
|
||||
`methodref_index` is an index (in this case a 2 byte index) into the class files `constant_pool`[^1]
|
||||
|
||||
|
||||
[^1]: https://docs.oracle.com/javase/specs/jvms/se23/html/jvms-4.html#jvms-4.1
|
||||
|
||||
> [!NOTE]
|
||||
> Highlights information that users should take into account, even when skimming.
|
||||
|
||||
> [!TIP]
|
||||
> Optional information to help a user be more successful.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Crucial information necessary for users to succeed.
|
||||
|
||||
> [!WARNING]
|
||||
> Critical content demanding immediate user attention due to potential risks.
|
||||
|
||||
> [!CAUTION]
|
||||
> Negative potential consequences of an action.
|
||||
|
||||
|
||||
## Stack manipulation
|
||||
|
||||
Sometimes it's
|
||||
|
||||
## Registers
|
||||
|
||||
# Stack Machine and Registers
|
||||
|
||||
# Decompilation
|
||||
|
||||
# Interlude, what's a stack map?
|
||||
|
||||
# Tracking everything everywhere
|
||||
|
||||
# Putting everything together
|
||||
|
||||
# Injection
|
||||
|
||||
|
||||
Take a look at the [GitHub](https://github.com/ParkerTenBroeck/generators)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```java,linenos
|
||||
public static Future<Void, IOException> echo(@Cancellation("close") Socket socket) throws IOException {
|
||||
public static Future<Void, IOException> echo(
|
||||
@Cancellation("close") Socket socket
|
||||
) throws IOException {
|
||||
try(socket){
|
||||
var buffer = ByteBuffer.allocate(4096*2);
|
||||
while(true){
|
||||
|
|
@ -24,4 +84,17 @@ public static Future<Void, IOException> echo(@Cancellation("close") Socket socke
|
|||
}
|
||||
```
|
||||
|
||||
Java (and other languages which compile for the JVM) operate on a
|
||||
|
||||
```java,linenos
|
||||
public static Gen<Long, Void> primes() {
|
||||
long number = 1;
|
||||
Gen.yield(2L);
|
||||
outer: while(true){
|
||||
number += 2;
|
||||
for(long i=2; i <= Math.sqrt(number); i ++){
|
||||
if(number%i==0)continue outer;
|
||||
}
|
||||
Gen.yield(number);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -61,7 +61,7 @@ Take a look at the [GitHub](https://github.com/ParkerTenBroeck/MyCPU_16bit)
|
|||
|
||||
|
||||
| Bit | Function |
|
||||
| --- | --- |
|
||||
| -- | ------------------------------------------ |
|
||||
| 31 | NA |
|
||||
| 30 | NA |
|
||||
| 29 | NA |
|
||||
|
|
|
|||
|
|
@ -172,3 +172,80 @@ th {
|
|||
}
|
||||
|
||||
|
||||
.markdown-alert-note {
|
||||
border-left: solid 3px var(--blue);
|
||||
padding-left: 20px;
|
||||
margin-left: 10px;
|
||||
|
||||
::before{
|
||||
content: "Note";
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--blue);
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-alert-note {
|
||||
border-left: solid 3px var(--blue);
|
||||
padding-left: 20px;
|
||||
margin-left: 10px;
|
||||
|
||||
::before{
|
||||
content: "Note";
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--blue);
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-alert-tip {
|
||||
border-left: solid 3px var(--green);
|
||||
padding-left: 20px;
|
||||
margin-left: 10px;
|
||||
|
||||
::before{
|
||||
content: "Tip";
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--green);
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-alert-important {
|
||||
border-left: solid 3px var(--purple);
|
||||
padding-left: 20px;
|
||||
margin-left: 10px;
|
||||
|
||||
::before{
|
||||
content: "Important";
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--purple);
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-alert-warning {
|
||||
border-left: solid 3px var(--yellow);
|
||||
padding-left: 20px;
|
||||
margin-left: 10px;
|
||||
|
||||
::before{
|
||||
content: "Warning";
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--yellow);
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-alert-caution {
|
||||
border-left: solid 3px var(--red);
|
||||
padding-left: 20px;
|
||||
margin-left: 10px;
|
||||
|
||||
::before{
|
||||
content: "Caution";
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
color: var(--red);
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,12 @@
|
|||
|
||||
--primary: light-dark(#ffd979, #daa520);
|
||||
--text-highlight: color-mix(in srgb-linear, var(--primary) 50%, transparent);
|
||||
|
||||
--blue: light-dark(#0969da, #1f6feb);
|
||||
--green: light-dark(#1a7f37, #3fb950);
|
||||
--purple: light-dark(#8250df, #ab7df8);
|
||||
--yellow: light-dark(#9a6700, #d29922);
|
||||
--red: light-dark(#d1242f, #f85149);
|
||||
}
|
||||
|
||||
* {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue