Skip to content

Instantly share code, notes, and snippets.

@prayagupa
Last active March 5, 2017 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prayagupa/89fe7da66cc3893add6ff2144015084c to your computer and use it in GitHub Desktop.
Save prayagupa/89fe7da66cc3893add6ff2144015084c to your computer and use it in GitHub Desktop.
bytecode

https://github.com/nihil-os/jasmin/blob/develop/examples/Arrays.j

write the bytecode using my text editor and run it

write a program with Java bytecode instructions directly?

https://en.wikipedia.org/wiki/Java_bytecode

https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings

invokevirtual -> calls actual type method

javap -v ClassName.class

.class public HelloWorld
.super java/lang/Object

.method public static main([Ljava/lang/String;)V
  .limit stack 3
  .limit locals 1

  getstatic      java/lang/System/out Ljava/io/PrintStream;
  ldc            "Today is my 2 years in The West."
  invokevirtual  java/io/PrintStream/println(Ljava/lang/String;)V

  return

.end method
@prayagupa
Copy link
Author

    static class Apple {
        public String color="";
    }
    public static void main(String[] args) {
        Apple apple = new Apple();
        apple.color = "blue";

        Apple apple1 = apple;
        apple1.color = "red";

        System.out.println(apple.color); // red
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment