Eclipse XBase Implementing Inner Classes

Here is an example I am using to experiment with inner classes.

Inner Class Scoping Example.

The following xbase example uses our usual grammar and jvmModelInferrer files. It uses default validation and scoping handling (no files other than those generated automatically).

As you can see from the diagram of the model generated, the inner class (MyTestInnerClass), is contained in the outer class (MyTestClass).

The contents of methods are an XBlockExpression and so are handled automatically by xbase.

inner class model

In the inferrer code the 'toClass' method for the inner class is called on the model element of the outer class. I have tried various combinations for the qualified name passed to this 'toClass' method, such as:

In all of these cases, as we can see from the screenshot, there are problems with referring to outer function from inner function.


When I commented out the lines with errors, then the code was generated correctly, except for the third case where the inner class name was called HelloWorld5$inner which is not necessary in java source code.

metadata block
see also:


Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2022 Martin John Baker - All rights reserved - privacy policy.