Not able to add classes in a directory to shared archive when using AppCDS
mehra.ashutosh at gmail.com
Thu Apr 5 09:15:11 UTC 2018
I am trying to use App CDS for a sample application.
My class files are in a directory which I specify as the classpath.
I want these classes to be included in shared archive.
Directory structure is like this:
│ ├── SampleClass.class
│ └── SampleClass.java
I performed following steps:
1. Create the class list:
$ java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=classes.list -cp
This generated the list of classes including my application classes TestCDS
2. Create the shared archive:
$ java -Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=classes.list
-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 0x00000008c0000000*
*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 jdk-dev