You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

32位机器加载大型ARXML文件时出现Java StackOverflowError

Fixing StackOverflowError When Loading ARXML with Java SE 8 on 32-bit Machines

Looking at your error stack trace and code, this is a classic stack overflow caused by circular dependencies during EPackage initialization in the Eclipse Modeling Framework (EMF). This issue hits the limits of the smaller default stack size in 32-bit JVMs much faster than in 64-bit environments.

What's Happening Under the Hood

Your stack trace shows a repeating cycle of calls like this:

at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:127)
at autosar40.diagnosticextract.dem.diagnosticoperationcycle.impl.DiagnosticoperationcyclePackageImpl.init(DiagnosticoperationcyclePackageImpl.java:1342)
at autosar40.diagnosticextract.dem.diagnosticoperationcycle.DiagnosticoperationcyclePackage.<clinit>(DiagnosticoperationcyclePackage.java:82)

This means multiple AUTOSAR EPackages are referencing each other during their static initialization. On a 32-bit JVM, the default stack size (usually around 512KB) isn't large enough to handle this recursive initialization chain, leading directly to the StackOverflowError.

Practical Solutions to Try

  • Switch to a 64-bit JVM (most reliable fix): 64-bit JVMs come with a larger default stack size (typically 1MB or more), which is almost always enough to handle these initialization cycles. If your environment allows this, this is the quickest and least complex fix.

  • Increase JVM stack size (if stuck on 32-bit): You can adjust the stack size using the -Xss JVM parameter. Try setting it to -Xss1m (1 megabyte) or -Xss2m (2 megabytes). Note that on 32-bit systems, you can't set this value too high without eating into available heap memory, so start with small increments and test.

  • Manually initialize EPackages upfront: If the above options aren't feasible, you can break the circular dependency by triggering the initialization of the affected packages before loading the ARXML file. Add this code right before your existing loading logic:

    // Initialize dependent packages explicitly to avoid recursive initialization during load
    autosar40.diagnosticextract.dem.diagnosticaging.DiagnosticagingPackage.eINSTANCE;
    autosar40.diagnosticextract.dem.diagnosticoperationcycle.DiagnosticoperationcyclePackage.eINSTANCE;
    autosar40.diagnosticextract.dem.diagnosticevent.DiagnosticeventPackage.eINSTANCE;
    
    // Proceed with your original ARXML loading code
    ifile.create(inputStreamObj, true, null); 
    ModelLoadManager.INSTANCE.loadFile(ifile, false, null);
    

    This pre-initializes the packages so their static setup doesn't happen recursively during the file load process.

Testing Steps

  1. First, try adjusting the -Xss parameter and rerun your code to see if the stack overflow disappears.
  2. If that fails, switch to a 64-bit JDK and test again.
  3. Only if both of the above aren't possible, implement the manual EPackage initialization approach.

内容的提问来源于stack exchange,提问作者sc560

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:15:22