Questions tagged [jvm-bytecode]

Questions about the JVM .class bytecode format or instruction set.

188 questions
6
votes
2 answers

Is java byte-code always forward compatible?

I understand that the byte code generated by version JDK X is guaranteed to work on JVM Y, provided Y >= X. Does this hold good for all versions of JDK/JVM? i.e Is it fair to expect class files generated by JDK 1 to work on JVM 11? Referred to JVM…
Sarvesh
  • 519
  • 1
  • 8
  • 16
6
votes
1 answer

Java 8: Merge String[] and int[] into Object[] when verifying bytecode

I'm reading section 4.10.2.2 of the specification for JVM version 8 (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html) how to verify bytecode. In this case what happens in control flow, when the stack now contains a slot with an int[]…
Emil
  • 16,784
  • 2
  • 41
  • 52
6
votes
3 answers

Writing languages for the JVM

Suppose I write a programming language; for namesake, I'll call it lang. To begin the long journey of writing lang, I decide to begin, by writing lang in itself. I can't actually run it, because theres nothing to run the program that runs itself. So…
user5549921
5
votes
1 answer

What's the value of the generated getClass invocation for method references?

I have the following contrived code example. It does nothing useful, in order to keep the bytecode small, but hopefully you can see how, with some changes, it might. List letters = Arrays.asList("a", "b"); Stream.of(/*a, b, c,…
Michael
  • 41,989
  • 11
  • 82
  • 128
5
votes
1 answer

Switch expression with help of arrow (->), and now can yield/return the value

The extended switch expression in Java 14, the need of switch expression is unclear other than visual clarity for programmer/reviewer. Is it a different byte code implementation than older switch expression? any performance improvement in terms of…
Jatish
  • 352
  • 1
  • 2
  • 10
5
votes
1 answer

Why does AspectJ generate an empty Annotation check?

I'm using AspectJ 1.8.8 compile-time weaving and I have a block like this @SomeAnnotation(value="someValue") public List doSomething(String someArg) { ... } where @SomeAnnotation is implemented with an "Around" advice. Looking at the bytecode…
Lycus
  • 410
  • 1
  • 6
  • 15
5
votes
2 answers

How does bipush work in JVM?

I understand iload takes in integers -1 to 5, but how can you extend to higher numbers using a bipush instruction? How is the specific integer being stored with the bytecode?
Tim
  • 138
  • 3
  • 8
5
votes
1 answer

Java Bytecode Signatures

As part of the compiler for the programming language I am working on, I came across generic signatures in the bytecode, which I am trying to parse and convert to an AST. The parsing algorithm mostly works, but there seems to be a special case in…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79
5
votes
2 answers

"throws" and "annotation for exception" in Dalvik bytecode

Why the byte code is generated as .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/FileNotFoundException; } .end annotation rather than .throws Ljava/io/FileNotFoundException if a method declares…
monica
  • 1,035
  • 1
  • 9
  • 21
4
votes
1 answer

Why does COMPUTE_FRAMES generate a lot of redundant instructions?

I'm writing a compiler that outputs JVM byte code, and using ASM 9.4 for the backend. This works fine, but I am puzzled about one particular quirk. I'm specifying COMPUTE_FRAMES to automatically compute the stack frames. It is said that the tradeoff…
rwallace
  • 31,405
  • 40
  • 123
  • 242
4
votes
2 answers

Does lambda () => 1 result in object creation at run time each time it is passed as an argument?

My understanding was that all non-capturing lambdas shouldn't require object creation at use site, because one can be created as a static field and reused. In principle, the same could be true for lambdas constituting of a class method call - only…
Turin
  • 2,208
  • 15
  • 23
4
votes
2 answers

java JVM bytecode notation, comment grammar. InvokeDynamic

Question: What does line 14 means? Use javap -v -c to disassembly the following code: public class test { static int i = 2; public static void main(String[] args) { test x = new test(); System.out.println("text +…
schen
  • 107
  • 1
  • 2
  • 7
4
votes
1 answer

Performance benefits of recompiling old java project with the latest java version

Does it make sense to recompile a project with a new (java 11) target version from a performance perspective if it will be run on a java 11 while source code will remain the same (java 8)? org.apache.maven.plugins
Serge
  • 2,574
  • 18
  • 26
4
votes
2 answers

Constructor bytecode

The ASM guide talks about constructors: package pkg; public class Bean { private int f; public int getF() { return this.f; } public void setF(int f) { this.f = f; } } The Bean class also has a default public constructor which…
rapt
  • 11,810
  • 35
  • 103
  • 145
4
votes
1 answer

Bytecode for Java string literals longer than 65535 bytes

I have been reading Java bytecode from a variety of files to help with my understanding of the .class files for a project where I need to integrate with a 3rd party library which has no source code and poor documentation available. For my own…
Mr Rho
  • 578
  • 3
  • 16
1
2
3
12 13