|
|
|
|
| Re: [Xcore] invoking constructor for Data Type [message #802599 is a reply to message #801478] |
Mon, 20 February 2012 01:44  |
Eclipse User |
|
|
|
Markus,
Comments below.
On 18/02/2012 2:00 PM, Markus Klink wrote:
> I can't get it to run unfortunately. I stripped down the model to a
> barebones sample and now it even crashes when I try to enter a value
> into the reflective editor. this is my xcore file:
>
> package x.y.z
>
> import x.y.z.util.Test
> import java.util.Date
> import java.text.SimpleDateFormat
>
> class SomeClass {
>
> Test something
> Date date
>
> }
>
> type Date wraps Date create {
> try {
> new SimpleDateFormat("yyyy-MM-dd").parse(it)
> } catch (Exception e) {
> throw new RuntimeException(e)
> }
> }
> convert {
> new SimpleDateFormat("yyyy-MM-dd").format(it)
> }
>
> type Test wraps Test
> create {
> new Test(it)
> }
> convert {
> it.toString
> }
>
> In the src folder I have the class x.y.z.util.Test
> package x.y.z.util;
>
> public class Test {
> private String text;
> public Test(String text) {
> this.text = text;
> }
>
> @Override
> public String toString() {
> return text;
> }
>
> }
I mentioned already that classes not actually installed in the
already-running IDE will not work in the reflective editor, so I don't
expect Test to work. Perhaps in the future we can play class loader
games (as I've done with dynamic JET templates), but that's not a
priority...
>
>
> I create a dynamic instance of SomeClass and view it in the reflective
> editor. I see the do fields, but neither in the Date nor in the test
> field I can enter something.
If I try the above, the stack trace from the error log is quite informative:
Caused by: java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1106)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:955)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:948)
at java.text.DateFormat.format(DateFormat.java:336)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
That makes it clear that the case of "it" being null isn't handled.
> If I do I see the spinning wheel of death and have to shutdown eclipse.
That is the danger of running things in the IDE process itself. Rogue
behavior can kill the process.
> I guess I am doing something really stupid
Overlooked handling null and expecting data types to work reflectively
for classes not reflectively accessible in the IDE...
> which I am missing, or maybe the combinations of my plugins does not
> cut it? If I can provide any other kind of debug information, please
> let me know.
When things go wrong, be sure to check the Error Log view for causes.
|
|
|
Powered by
FUDForum. Page generated in 0.03858 seconds