This page is no longer maintained — Please continue to the home page at www.scala-lang.org

model factory and javap

No replies
Filip Rogaczewski
Joined: 2010-04-06,
User offline. Last seen 42 years 45 weeks ago.

Hi,
I am writing master thesis on Scala and Java interoperobability. My
master project Scajadoc generates Java API from Scala sources. At the
moment I am struggling with generating list of all implemented
interfaces. Lets have a look at ModelFactory from Scajadoc:
https://github.com/frogaczewski/Scajadoc/blob/master/core/src/main/scala...
The only difference from scala.tools.nsc.doc.model.ModelFactory I made
is addition of the following lines:
def interfaces = {
sym.info.parents.map(_.typeSymbol).filter(s => s.isInterface
|| s.isTrait).map(makeTemplate(_))
}
in definition of DocTemplateImpl (lines 161:234).

What I've observed is a difference between results I get using jclasslib
bytecode viewer, reflection or javap and results generated by model factory.
1) ScalaObject is never on ModelFactory's list of interfaces. It was
turned into AnyRef by template normalization (method from ModelFactory).
Obviously, I can change AnyRef back to ScalaObject. The question for my
master thesis is: why is ScalaObject turned into AnyRef, while AnyRef is
equivalent to java.lang.Object and ScalaObject is just an interface
(from Java perspective of course).

2) Please have a look at the following differences
- case class DistributedAlgorithm
model factory: ScalaObject, Product
javap: ScalaObject, Product, Serializable

- case object HSDistributedAlgorithm extends DistributedAlgorithm("HS",
None)
model factory: ScalaObject, Product
javap: ScalaObject, Product, Serializable
- @serializable class HSAlgorithm extends Algorithm
model factory: ScalaObject, Algorithm
javap: ScalaObject, Algorithm, Serializable

for some reason there is no Serializable on the parents or the ancestors
lists. java.io.Serializable may be found on the list of exceptions
ancestors, but in this case serialization comes from java.lang.Throwable.
What am I missing?

Best,
Filip Rogaczewski

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland