Gang,
I am working on formalizing the Scala support in a couple of steps;
1. Moved Rickard's sample into Core API. Done a few weeks ago.
2. I am currently refactoring Rickard's code; Didn't like that the
AppliesTo check has sideeffects of populating a static member in
TraitMixin. To enable the effective use of doing that initialization
in the TraitMixin constructor, I introduced "@Invocation
Iterable<Method> invocations", which gives all methods that are assign
to a Mixin implementation. A bit hackish and will probably go away
once step 3 kicks in.
3. Kill the TraitMixin and embedd the recognition of Scala trait
inside the Core Runtime and do the wiring automatically when detected.
A couple of things has come up;
First, the Scala compiler produces different ordering for traits than
the equivalent of interfaces in the javac. So for,
trait HelloWorldComposite
extends TransientComposite with HelloWorldMixin with HelloWorldMixin2
the Qi4j Runtime end up producing the following ordering;
org.qi4j.api.composite.TransientComposite
org.qi4j.sample.scala.HelloWorldMixin2
scala.ScalaObject
org.qi4j.sample.scala.HelloWorldComposite
org.qi4j.sample.scala.HelloWorldMixin
org.qi4j.api.composite.Composite
which seems to me to be fairly random.
What worries me is that the Scala compiler is capable of compiling
Java code as well, at the same time. I wonder if it will ever happen
that Java bytecodes end up in the application code (javac sees them as
up-to-date and skips compilation). Anyone knows?? It would mean that
the current "first element == primary type", no longer applies.
Secondly,
Are we Ok with a Scala dependency on Qi4j Core??
At this very moment on my local copy, I do
private boolean isScalaTrait( Class<?> declaringClass )
{
return ScalaObject.class.isAssignableFrom( declaringClass );
}
but, I could modify that to walk the parents and see if any (top one)
is named "scala.ScalaObject" instead.
At the moment, this is the only Scala dependency in here, but I am
pretty sure that soon we should add Scala collection support and
possibly other useful types for serialization. So, shall I delay the
introduction of the Scala dependency, or Ok to put it in right away
and give people some time to get the IDEs to work with Scala (was not
trivial for me)?
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
I live here; http://tinyurl.com/3xugrbk
I work here; http://tinyurl.com/6a2pl4j
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev