Not able to add classes in a directory to shared archive when using AppCDS
mikhailo.seledtsov at oracle.com
Thu Apr 5 17:39:16 UTC 2018
Jiangli replied with an answer to your question on
hotspot-runtime-dev at openjdk.java.net.
On 4/5/18, 10:22 AM, ashutosh mehra wrote:
> Any reason why AppCDS does not support archival of straight classes?
> On Thu, Apr 5, 2018 at 7:30 PM, Mikhailo Seledtsov
> <mikhailo.seledtsov at oracle.com <mailto:mikhailo.seledtsov at oracle.com>>
> Hi Ashutosh,
> I believe that AppCDS does not support archival of straight
> classes. Please add classes to the jar first, use -cp path-to-jar
> when generating the archive. Make sure class path does not include
> any directories that has straight class files (.class), or you
> will get the same error.
> When running with archive, use the same class path as was used
> during the generation of the archive.
> I hope this is helpful,
> Best regards,
> On 4/5/18, 2:15 AM, ashutosh mehra wrote:
> I am trying to use App CDS for a sample application.
> My class files are in a directory which I specify as the
> I want these classes to be included in shared archive.
> Directory structure is like this:
> $ tree
> ├── classes
> │ ├── SampleClass.class
> │ └── SampleClass.java
> ├── TestCDS.class
> └── TestCDS.java
> I performed following steps:
> 1. Create the class list:
> $ java -Xshare:off -XX:+UseAppCDS
> -XX:DumpLoadedClassList=classes.list -cp
> .:classes TestCDS
> This generated the list of classes including my application
> classes TestCDS
> and SampleClass.
> 2. Create the shared archive:
> $ java -Xshare:dump -XX:+UseAppCDS
> -XX:SharedArchiveFile=mycds.jcs -cp .:classes
> I get following error message:
> *narrow_klass_base = 0x0000000800000000, narrow_klass_shift = 3*
> *Allocated temporary class space: 1073741824 bytes at
> *Allocated shared space: 3221225472 bytes at 0x0000000800000000*
> *Error: non-empty directory '.'*
> *Hint: enable -Xlog:class+path=info to diagnose the failure*
> *Error occurred during initialization of VM*
> *CDS allows only empty directories in archived classpaths*
> Java version is:
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
> I have also tried with Java 11 EA build but got same output.
> Is this expected behavior? I am sure it would be useful for
> many if the
> classes loaded from a directory can also be stored in the
> shared archive.
More information about the hotspot-runtime-dev