Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » ecore & ocl generated classes: ExceptionInInitializerError
icon4.gif  ecore & ocl generated classes: ExceptionInInitializerError [message #1245159] Thu, 13 February 2014 11:40 Go to next message
Christoph Caks is currently offline Christoph CaksFriend
Messages: 10
Registered: July 2009
Junior Member
I found an issue with the generated *Tables classes

they all essentially look like this
public class ClassA {

	public static final Object FIELD = new Object();
	
	public static class InnerA {
		public final static String INNER_FIELD = "Inner" + FIELD.getClass();
		
		public final static String[] inner =  {
			INNER_FIELD
		};
	}
	
	static {
		InnerA.inner[0].getClass();
	}
	
}


and if InnerA's initializer is called before ClassA's initializer you get a NPE at the array access

here is a stacktrace to illustrate the issue
Exception in thread "main" java.lang.ExceptionInInitializerError
	at beep.ClassA$InnerA.<clinit>(ClassA.java:8)
	at beep.Main.main(Main.java:10)
Caused by: java.lang.NullPointerException
	at beep.ClassA.<clinit>(ClassA.java:16)
	... 2 more


and this is exactly what happens when another *Tables class is initialized

i work around this by adding something like DependendTables.PACKAGE.getClass() before the array access, but this change is lost every time i regenerate

[Updated on: Thu, 13 February 2014 11:42]

Report message to a moderator

Re: ecore &amp; ocl generated classes: ExceptionInInitializerError [message #1245190 is a reply to message #1245159] Thu, 13 February 2014 12:39 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This is/was https://bugs.eclipse.org/bugs/show_bug.cgi?id=415381.

If you use any Luna milestone buiold after M2, e.g.

http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/5.0.0/S201401270935/mdt-ocl-Update-5.0.0M5.zip

which should be installable on Kepler the problem should be fixed.

Regards

Ed Willink

On 13/02/2014 11:40, Christoph Caks wrote:
> I found an issue with the generated *Tables classes
>
> they all essentially look like this
>
> public class ClassA {
>
> public static final Object FIELD = new Object();
>
> public static class InnerA {
> public final static String INNER_FIELD = "Inner" +
> FIELD.getClass();
>
> public final static String[] inner = {
> INNER_FIELD
> };
> }
>
> static {
> InnerA.inner[0].getClass();
> }
>
> }
>
>
> and if InnerA's initializer is called before ClassA's initializer you
> get a NPE at the array access
>
> and this is exactly what happens when another *Tables class is
> initialized
>
> i work around this by adding something like
> DependendTables.PACKAGE.getClass() before the array access, but this
> change is lost every time i regenerate
Previous Topic:[CompleteOCL] getValue of property direction of FlowPort
Next Topic:ecore & ocl: dependencies
Goto Forum:
  


Current Time: Thu Apr 25 10:37:20 GMT 2024

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

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

Back to the top