strange compilation error

26 views
Skip to first unread message

Mirco Coppola

unread,
Oct 19, 2015, 5:11:37 AM10/19/15
to Scala IDE Dev
Hi,

i have software project under scala-ide with mixed java and scala classes. I have a class named BulkImporter.scala and another class named Dispatcher.java.

 In Dispatcher.java i wrote:
.....

 if (response instanceof BulkImporter.Accepted$) {.....code...}

.....
The scala-ide give me  a compilation error:  BulkImporter.Accepted$ cannot be resolved to a type . Why?

I tried with another IDE and no compilation error found.

Can you help me please?

Many thanks
Mirco

Simon Schäfer

unread,
Oct 19, 2015, 5:43:01 AM10/19/15
to scala-...@googlegroups.com


On 10/19/2015 11:08 AM, Mirco Coppola wrote:
Hi,

i have software project under scala-ide with mixed java and scala classes. I have a class named BulkImporter.scala and another class named Dispatcher.java.

 In Dispatcher.java i wrote:
.....

 if (response instanceof BulkImporter.Accepted$) {.....code...}

.....
The scala-ide give me  a compilation error:  BulkImporter.Accepted$ cannot be resolved to a type . Why?
How is Accepted defined?

I tried with another IDE and no compilation error found.

Can you help me please?

Many thanks
Mirco

--
You received this message because you are subscribed to the Google Groups "Scala IDE Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-dev/24a655f4-60b9-4982-ab77-1e8b20ab488d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mirco Coppola

unread,
Oct 19, 2015, 5:52:10 AM10/19/15
to Scala IDE Dev
Hi Simon,

many thanks for the quick response. Accepted is defined in a BulkImporter object. BulkImporter is a actor. I have attached the complete file.

object BulkImporter {

  trait Response {}

  case class ImportAll(completeImport: Try[Any] => Unit)

  case object Accepted extends Response

  case object Refused extends Response

  case class ImporterConfiguration(batchSize: Int,
                                   workerCount: Int,
                                   enricherCount: Int,
                                   solrRequesterCount: Int,
                                   maxRows: Long)

}

Thanks!
BulkImporter.scala

Simon Schäfer

unread,
Oct 19, 2015, 11:02:12 AM10/19/15
to scala-...@googlegroups.com


On 10/19/2015 11:52 AM, Mirco Coppola wrote:
Hi Simon,

many thanks for the quick response. Accepted is defined in a BulkImporter object. BulkImporter is a actor. I have attached the complete file.
I think this is a bug in Eclipse Java support. Nothing we can do here. I suggest to not use scalac generates symbols from Java. If you need Java interop I would create a Java enum and send the enum to the Java consumer, this way you shouldn't get into any trouble regarding synthetic names.

object BulkImporter {

  trait Response {}

  case class ImportAll(completeImport: Try[Any] => Unit)

  case object Accepted extends Response

  case object Refused extends Response

  case class ImporterConfiguration(batchSize: Int,
                                   workerCount: Int,
                                   enricherCount: Int,
                                   solrRequesterCount: Int,
                                   maxRows: Long)

}

Thanks!
--
You received this message because you are subscribed to the Google Groups "Scala IDE Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-de...@googlegroups.com.

iulian dragos

unread,
Oct 20, 2015, 4:41:15 AM10/20/15
to scala-ide-dev
Just to add a suggestion to Simon's answer. Java interoperability is easiest when you stick to Java-like Scala (of course, this only needs to happen in the areas of contact). So, there's no top-level objects in Java, so better avoid them. I don't think you lose anything by moving all `case classes` to top-level.

Lastly, there are subtle differences between the Eclipse Java compiler and the Oracle Java compiler, so you'll sometimes have code that compiles in one but not the other. I guess the EJC could be fixed, if you wish you could try to open a ticket on the Eclipse issue tracker.

iulian

 
Thanks!

--
You received this message because you are subscribed to the Google Groups "Scala IDE Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-dev/71987574-d441-4877-8b19-fc74552758e8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Reply all
Reply to author
Forward
0 new messages