Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF, Java 8 and sun.misc.Unsafe.ensureClassInitialized(
EMF, Java 8 and sun.misc.Unsafe.ensureClassInitialized( [message #1492134] Sat, 29 November 2014 15:25 Go to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Dear all,

we have a EMF project that builds fine with JDK 1.7 and Tycho (test cases in surefire) when mvn/Tycho runs with a Java 1.7.

However, running Tycho with a JDK 1.8 used to work, and now it breaks

.mavenrc:
export JAVA_HOME="C:\\Program Files\\Java\\jdk1.8.0_25"

Now the test cases fail because we see:

ava.lang.NoClassDefFoundError: Could not initialize class com.x.x.x.XPackage
	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
	at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1082)
	at java.lang.reflect.Field.getFieldAccessor(Field.java:1063)
	at java.lang.reflect.Field.get(Field.java:387)
	at org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor.getEPackage(RegistryReader.java:273)
	at org.eclipse.emf.ecore.impl.EPackageImpl$1.getEPackage(EPackageImpl.java:163)
	at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:127)
	at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.delegatedGetEPackage(EPackageRegistryImpl.java:190)
	at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:143)
	at org.eclipse.emf.ecore.util.BasicExtendedMetaData.getPackage(BasicExtendedMetaData.java:113)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2494)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2458)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1335)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1504)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:77)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
	at org.eclipse.sphinx.emf.resource.ExtendedXMLLoadImpl.load(ExtendedXMLLoadImpl.java:194)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
	at org.eclipse.sphinx.emf.util.EcoreResourceUtil.loadResource(EcoreResourceUtil.java:1152)
	at org.eclipse.sphinx.emf.util.EcoreResourceUtil.loadResource(EcoreResourceUtil.java:788)
	at org.eclipse.sphinx.emf.util.EcorePlatformUtil$7.run(EcorePlatformUtil.java:690)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.emf.transaction.util.TransactionUtil.runExclusive(TransactionUtil.java:328)
	at org.eclipse.sphinx.emf.util.EcorePlatformUtil.loadResource(EcorePlatformUtil.java:686)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager$4.run(ModelLoadManager.java:774)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.loadModelFilesInEditingDomain(ModelLoadManager.java:749)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.runLoadModelFiles(ModelLoadManager.java:731)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.runDetectAndLoadModelFiles(ModelLoadManager.java:712)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.runLoadProjects(ModelLoadManager.java:591)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.access$0(ModelLoadManager.java:568)
	at org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager$2.run(ModelLoadManager.java:541)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Any ideas what the reason could be?

Thanks in advance,

Andreas
Re: EMF, Java 8 and sun.misc.Unsafe.ensureClassInitialized( [message #1494174 is a reply to message #1492134] Mon, 01 December 2014 08:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30351
Registered: July 2009
Senior Member
Andreas,

Comments below.

On 29/11/2014 4:25 PM, Andreas Graf wrote:
> Dear all,
>
> we have a EMF project that builds fine with JDK 1.7 and Tycho (test
> cases in surefire) when mvn/Tycho runs with a Java 1.7.
The stack you show below looks like a workspace job. Is this really
running as an Eclipse application or some for of stand-alone where
Surefire sets the classpath? Certainly it looks like a registry
reader is involved so it looks like a real Eclipse application running,
but in that case, how is Surefire needed?

Also note that the exception might look like the class can't be found,
but it could instead be a case that there is an exception initializing
the package class instance and you don't see the stack trace for that.
That could be an issue of threading. E.g., several threads trying to
load the same class at the same time. The behavior of the class loader
is a bit funky is such cases where it might return null for static final
constants you'd never expect could ever be null.
>
> However, running Tycho with a JDK 1.8 used to work, and now it breaks
>
> mavenrc:
> export JAVA_HOME="C:\\Program Files\\Java\\jdk1.8.0_25"
>
> Now the test cases fail because we see:
>
>
> ava.lang.NoClassDefFoundError: Could not initialize class
> com.x.x.x.XPackage
> at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> at
> sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
> at
> sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
> at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1082)
> at java.lang.reflect.Field.getFieldAccessor(Field.java:1063)
> at java.lang.reflect.Field.get(Field.java:387)
> at
> org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor.getEPackage(RegistryReader.java:273)
> at
> org.eclipse.emf.ecore.impl.EPackageImpl$1.getEPackage(EPackageImpl.java:163)
> at
> org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:127)
> at
> org.eclipse.emf.ecore.impl.EPackageRegistryImpl.delegatedGetEPackage(EPackageRegistryImpl.java:190)
> at
> org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:143)
> at
> org.eclipse.emf.ecore.util.BasicExtendedMetaData.getPackage(BasicExtendedMetaData.java:113)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2494)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2458)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1335)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1504)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:77)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at
> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> at
> org.eclipse.sphinx.emf.resource.ExtendedXMLLoadImpl.load(ExtendedXMLLoadImpl.java:194)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
> at
> org.eclipse.sphinx.emf.util.EcoreResourceUtil.loadResource(EcoreResourceUtil.java:1152)
> at
> org.eclipse.sphinx.emf.util.EcoreResourceUtil.loadResource(EcoreResourceUtil.java:788)
> at
> org.eclipse.sphinx.emf.util.EcorePlatformUtil$7.run(EcorePlatformUtil.java:690)
> at
> org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
> at
> org.eclipse.emf.transaction.util.TransactionUtil.runExclusive(TransactionUtil.java:328)
> at
> org.eclipse.sphinx.emf.util.EcorePlatformUtil.loadResource(EcorePlatformUtil.java:686)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager$4.run(ModelLoadManager.java:774)
> at
> org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.loadModelFilesInEditingDomain(ModelLoadManager.java:749)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.runLoadModelFiles(ModelLoadManager.java:731)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.runDetectAndLoadModelFiles(ModelLoadManager.java:712)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.runLoadProjects(ModelLoadManager.java:591)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager.access$0(ModelLoadManager.java:568)
> at
> org.eclipse.sphinx.emf.workspace.loading.ModelLoadManager$2.run(ModelLoadManager.java:541)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
>
>
> Any ideas what the reason could be?
>
> Thanks in advance,
>
> Andreas
Re: EMF, Java 8 and sun.misc.Unsafe.ensureClassInitialized( [message #1494196 is a reply to message #1494174] Mon, 01 December 2014 08:57 Go to previous message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Hi Ed,

thanks for you replay. This morning I found out that I overlooked that the test / application was started with an old version of Yourkit profiling it. And that cannot deal with Java 8. Removed yourkit and it worked fine. Newest version of Yourkit also fails.
Cost me two days, since nowhere in the error message Yourkit is mentioned.

Regards,

Andreas
Previous Topic:XMI file
Next Topic:Custom EMF-based TreeViewer for E4
Goto Forum:
  


Current Time: Mon Aug 19 03:38:35 GMT 2019

Powered by FUDForum. Page generated in 0.01963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top