#1267 Unable to decode facet

qualidafial Wed 27 Oct 2010

I'm running into a weird error with facets. Given this facet class:

facet class Bindable
{
  const Obj eventType
}

And this class:

class Bean
{
  @Bindable { eventType = Bean#a }
  Obj? a
}

When I try to read the facet:

facet := Bean#a.facet(Bindable#, false)

I get this error:

ERROR: Cannot decode facet bind::Bindable: bind::Bindable{eventType=bind::Bean#name;}
sys::IOErr: Expected end of statement: semicolon, newline, or end of block; not 'identifier' [Line 1]
	at fan.sys.IOErr.<init>(IOErr.java:45)
	at fan.sys.IOErr.make(IOErr.java:31)
	at fan.sys.IOErr.make(IOErr.java:21)
	at fanx.serial.ObjDecoder.err(ObjDecoder.java:656)
	at fanx.serial.ObjDecoder.err(ObjDecoder.java:653)
	at fanx.serial.ObjDecoder.err(ObjDecoder.java:664)
	at fanx.serial.ObjDecoder.endOfStmt(ObjDecoder.java:730)
	at fanx.serial.ObjDecoder.readComplexFields(ObjDecoder.java:299)
	at fanx.serial.ObjDecoder.readComplex(ObjDecoder.java:209)
	at fanx.serial.ObjDecoder.readObj(ObjDecoder.java:146)
	at fanx.serial.ObjDecoder.readObj(ObjDecoder.java:55)
	at fanx.serial.ObjDecoder.decode(ObjDecoder.java:28)
	at fan.sys.Facets.decode(Facets.java:82)
	at fan.sys.Facets.get(Facets.java:66)
	at fan.sys.Slot.facet(Slot.java:115)

The weird thing is the facet in the error message is serialized as Bindable{eventType=Bean#name} instead of eventType=Bean#a like I expected.

Any ideas what I'm doing wrong here?

brian Wed 27 Oct 2010

The core problem is that Slot literals are not serializable, although obviously the error handling is pretty wacked. Is should have been caught at compile time. So I will need to take a look.

brian Wed 27 Oct 2010

I pushed a fix to catch this at compile time.

Now the real question is should slot literals be serializable? I don't see why not and I'm not sure why we didn't do that when I added type literals to serialization syntax. But if anybody would like to discuss, let's create a new issue to track it.

qualidafial Wed 27 Oct 2010

Obviously I vote yes since it would support the work I'm doing now. :)

I'm curious, are pod and class literals serializable now?

brian Wed 27 Oct 2010

Type literals are supported:

fansh> Env.cur.out.writeObj(Str#).printLine
sys::Str#

I will create ticket for slot literals

Login or Signup to reply.