The TypeLibrary class is not properly protected from concurrent access. This can happen when creating dynamic events. A typical exception can look like this:
Exception in thread "main" java.lang.ExceptionInInitializerError
at jdk.jfr/jdk.jfr.EventFactory.create(EventFactory.java:169)
...
Caused by: java.lang.ArrayIndexOutOfBoundsException\cf2 : Index 233 out of bounds for length 233
at java.base/java.util.LinkedHashMap.valuesToArray(LinkedHashMap.java:555)
at java.base/java.util.LinkedHashMap$LinkedValues.toArray(LinkedHashMap.java:635)
at java.base/java.util.ArrayList.<init>(ArrayList.java:181)
at jdk.jfr/jdk.jfr.internal.TypeLibrary.getTypes(TypeLibrary.java:122)
at jdk.jfr/jdk.jfr.internal.MetadataRepository.initializeJVMEventTypes(MetadataRepository.java:74)
at jdk.jfr/jdk.jfr.internal.MetadataRepository.<init>(MetadataRepository.java:69)
at jdk.jfr/jdk.jfr.internal.MetadataRepository.<clinit>(MetadataRepository.java:56)
Normally all access to metadata requires the "metadata lock", but there are some exceptions. Problem is that the TypeLibrary can't depend on MetadataRepository class without a recursion. Some of this dealt with by using the TypeLibrary class lock, but not in all places.
Exception in thread "main" java.lang.ExceptionInInitializerError
at jdk.jfr/jdk.jfr.EventFactory.create(EventFactory.java:169)
...
Caused by: java.lang.ArrayIndexOutOfBoundsException\cf2 : Index 233 out of bounds for length 233
at java.base/java.util.LinkedHashMap.valuesToArray(LinkedHashMap.java:555)
at java.base/java.util.LinkedHashMap$LinkedValues.toArray(LinkedHashMap.java:635)
at java.base/java.util.ArrayList.<init>(ArrayList.java:181)
at jdk.jfr/jdk.jfr.internal.TypeLibrary.getTypes(TypeLibrary.java:122)
at jdk.jfr/jdk.jfr.internal.MetadataRepository.initializeJVMEventTypes(MetadataRepository.java:74)
at jdk.jfr/jdk.jfr.internal.MetadataRepository.<init>(MetadataRepository.java:69)
at jdk.jfr/jdk.jfr.internal.MetadataRepository.<clinit>(MetadataRepository.java:56)
Normally all access to metadata requires the "metadata lock", but there are some exceptions. Problem is that the TypeLibrary can't depend on MetadataRepository class without a recursion. Some of this dealt with by using the TypeLibrary class lock, but not in all places.
- relates to
-
JDK-8307298 JFR: Ensure jdk.jfr.internal.TypeLibrary is initialized only once
-
- Resolved
-