7

I'm trying to know whether creating a Class Data Sharing archive (by running java -Xshare:dump) compiles byte code into native code.

There is not a lot of documentation about the internals of Class Data Sharing. The page I linked says that java -Xshare:dump

loads a set of classes from the system jar file into a private internal representation, and dumps that representation to a file.

But says nothing about whether this code is compiled or not.

(Possibly related: Speed up application start by adding own application classes to classes.jsa)

Community
  • 1
  • 1
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234

1 Answers1

2

In both cases it's native code in the cache (see the discussion in the link you provided about regenerating the cache on machines of different architecture). The IBM JVM takes it further with more options and a nicer layout for clusters, but the Oracle one works too.

WPrecht
  • 1,340
  • 1
  • 17
  • 29
  • What exactly makes you say that it's native code? The "different architectures" question just means that the layout of the class archive file depends on the OS (size of ptrs, etc.) and does not immediately imply that the code is natively compiled. – Jean-Philippe Pellet Feb 22 '13 at 14:35
  • Because there's no intermediate step. It's source->byte code->native. Only at the native step do you care about things like endienness, word size, etc. There is also reference in the documentation to the fact that cache classes may not be as performant as JIT compiled classes. This implies that the cached classes are executable as is since JIT takes advantage of all the shortcuts available on any specific hardware which can vary greatly in even compatible architectures as well as specific execution patterns in that JVM. So the classes coming in from the cache are not further compiled. – WPrecht Feb 22 '13 at 14:47