- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
2.8.1 java/scala order sensitivity in Pres. Compiler
Sun, 2010-09-26, 00:22
I'm experiencing a problem in 2.8.1.RC1 where types declared in Java
sources won't be found if the .java source is listed before the .scala
source. The order doesn't seem to matter in 2.8.0.
Any thoughts on what changed?
The following will reproduce:
----------Main.scala--------------------------
import scala.tools.nsc.Settings
import scala.tools.nsc.reporters.ConsoleReporter
import scala.tools.nsc.interactive.Global
object Main{
def main(args:Array[String]){
val settings = new Settings(Console.println)
settings.processArguments(List("-verbose", "-sourcepath", "."), false)
val reporter = new ConsoleReporter(settings)
val c = new Global(settings, reporter)
val x = new c.Response[Unit]()
// change the order of sources below to
// get rid of error
c.askReload(List(
c.getSourceFile("Orange.java"),
c.getSourceFile("Apple.scala")
), x)
x.get
}
}
-------------------------------------------------------
-----------------Apple.scala---------------------------
object Apple{
def main{
println(new Orange())
}
}
-------------------------------------------------------
----------------Orange.java---------------------------
public class Orange{
public static String FLAVOR = "sweet";
}
Sun, 2010-09-26, 08:37
#2
Re: 2.8.1 java/scala order sensitivity in Pres. Compiler
Looks like the issue is on the background compilation thread, in some
new top-level symbol tracking code.
From scala.tools.nsc.interactive.Global
-----------------------------------------
def recompile(units: List[RichCompilationUnit]) {
for (unit <- units) {
reset(unit)
if (debugIDE) inform("parsing: "+unit)
parse(unit)
}
for (unit <- units) {
if (debugIDE) inform("type checking: "+unit)
activeLocks = 0
currentTyperRun.typeCheck(unit)
unit.status = currentRunId
syncTopLevelSyms(unit)
}
}
def syncTopLevelSyms(unit: RichCompilationUnit) {
val deleted = currentTopLevelSyms filter { sym =>
sym.sourceFile == unit.source.file && runId(sym.validTo) <
currentRunId
}
for (d <- deleted) {
d.owner.info.decls unlink d
deletedTopLevelSyms += d
currentTopLevelSyms -= d
}
}
----------------------------------------
Java symbols are being classified as deleted because their runId is not
equal to currentRunId after type-checking.
Should I open a ticket for this?
On 09/25/2010 09:13 PM, Paul Phillips wrote:
> On Sat, Sep 25, 2010 at 04:22:16PM -0700, Aemon Cannon wrote:
>> I'm experiencing a problem in 2.8.1.RC1 where types declared in Java
>> sources won't be found if the .java source is listed before the .scala
>> source. The order doesn't seem to matter in 2.8.0.
>>
>> Any thoughts on what changed?
>
> The behavior looks the same to me, up to the point where 2.8 exits. The
> difference I observe is that 2.8 calls it a day after the code runs and
> 2.9 seems to take on a life of its own, and it's during this second life
> that it complains about not finding the java class.
>
> I imagine a background thread is being started somewhere.
>
Sun, 2010-09-26, 09:17
#3
Re: Re: 2.8.1 java/scala order sensitivity in Pres. Compiler
On Sun, Sep 26, 2010 at 8:29 AM, Aemon Cannon wrote:
> Java symbols are being classified as deleted because their runId is not
> equal to currentRunId after type-checking.
>
> Should I open a ticket for this?
Yes, definitely ...
Cheers,
Miles
Sun, 2010-09-26, 11:17
#4
Re: Re: 2.8.1 java/scala order sensitivity in Pres. Compiler
Hello Aemon,
Yes, please file a ticket and we'll try to fix it ASAP.
Cheers,
Eugene.
On Sun, Sep 26, 2010 at 11:29 AM, Aemon Cannon wrote:
> Looks like the issue is on the background compilation thread, in some new
> top-level symbol tracking code.
>
> From scala.tools.nsc.interactive.Global
> -----------------------------------------
>
> def recompile(units: List[RichCompilationUnit]) {
> for (unit <- units) {
> reset(unit)
> if (debugIDE) inform("parsing: "+unit)
> parse(unit)
> }
> for (unit <- units) {
> if (debugIDE) inform("type checking: "+unit)
> activeLocks = 0
> currentTyperRun.typeCheck(unit)
> unit.status = currentRunId
> syncTopLevelSyms(unit)
> }
> }
>
> def syncTopLevelSyms(unit: RichCompilationUnit) {
> val deleted = currentTopLevelSyms filter { sym =>
> sym.sourceFile == unit.source.file && runId(sym.validTo) < currentRunId
> }
> for (d <- deleted) {
> d.owner.info.decls unlink d
> deletedTopLevelSyms += d
> currentTopLevelSyms -= d
> }
> }
> ----------------------------------------
>
>
> Java symbols are being classified as deleted because their runId is not
> equal to currentRunId after type-checking.
>
> Should I open a ticket for this?
>
>
>
>
>
> On 09/25/2010 09:13 PM, Paul Phillips wrote:
>>
>> On Sat, Sep 25, 2010 at 04:22:16PM -0700, Aemon Cannon wrote:
>>>
>>> I'm experiencing a problem in 2.8.1.RC1 where types declared in Java
>>> sources won't be found if the .java source is listed before the .scala
>>> source. The order doesn't seem to matter in 2.8.0.
>>>
>>> Any thoughts on what changed?
>>
>> The behavior looks the same to me, up to the point where 2.8 exits. The
>> difference I observe is that 2.8 calls it a day after the code runs and
>> 2.9 seems to take on a life of its own, and it's during this second life
>> that it complains about not finding the java class.
>>
>> I imagine a background thread is being started somewhere.
>>
>
>
>
Sun, 2010-09-26, 18:27
#5
Re: 2.8.1 java/scala order sensitivity in Pres. Compiler
Great!
Here's the ticket:
https://lampsvn.epfl.ch/trac/scala/ticket/3875
On 09/26/2010 03:15 AM, Eugene Vigdorchik wrote:
> Hello Aemon,
> Yes, please file a ticket and we'll try to fix it ASAP.
>
> Cheers,
> Eugene.
>
> On Sun, Sep 26, 2010 at 11:29 AM, Aemon Cannon wrote:
>> Looks like the issue is on the background compilation thread, in some new
>> top-level symbol tracking code.
>>
>> From scala.tools.nsc.interactive.Global
>> -----------------------------------------
>>
>> def recompile(units: List[RichCompilationUnit]) {
>> for (unit<- units) {
>> reset(unit)
>> if (debugIDE) inform("parsing: "+unit)
>> parse(unit)
>> }
>> for (unit<- units) {
>> if (debugIDE) inform("type checking: "+unit)
>> activeLocks = 0
>> currentTyperRun.typeCheck(unit)
>> unit.status = currentRunId
>> syncTopLevelSyms(unit)
>> }
>> }
>>
>> def syncTopLevelSyms(unit: RichCompilationUnit) {
>> val deleted = currentTopLevelSyms filter { sym =>
>> sym.sourceFile == unit.source.file&& runId(sym.validTo)< currentRunId
>> }
>> for (d<- deleted) {
>> d.owner.info.decls unlink d
>> deletedTopLevelSyms += d
>> currentTopLevelSyms -= d
>> }
>> }
>> ----------------------------------------
>>
>>
>> Java symbols are being classified as deleted because their runId is not
>> equal to currentRunId after type-checking.
>>
>> Should I open a ticket for this?
>>
>>
>>
>>
>>
>> On 09/25/2010 09:13 PM, Paul Phillips wrote:
>>>
>>> On Sat, Sep 25, 2010 at 04:22:16PM -0700, Aemon Cannon wrote:
>>>>
>>>> I'm experiencing a problem in 2.8.1.RC1 where types declared in Java
>>>> sources won't be found if the .java source is listed before the .scala
>>>> source. The order doesn't seem to matter in 2.8.0.
>>>>
>>>> Any thoughts on what changed?
>>>
>>> The behavior looks the same to me, up to the point where 2.8 exits. The
>>> difference I observe is that 2.8 calls it a day after the code runs and
>>> 2.9 seems to take on a life of its own, and it's during this second life
>>> that it complains about not finding the java class.
>>>
>>> I imagine a background thread is being started somewhere.
>>>
>>
>>
>>
>
On Sat, Sep 25, 2010 at 04:22:16PM -0700, Aemon Cannon wrote:
> I'm experiencing a problem in 2.8.1.RC1 where types declared in Java
> sources won't be found if the .java source is listed before the .scala
> source. The order doesn't seem to matter in 2.8.0.
>
> Any thoughts on what changed?
The behavior looks the same to me, up to the point where 2.8 exits. The
difference I observe is that 2.8 calls it a day after the code runs and
2.9 seems to take on a life of its own, and it's during this second life
that it complains about not finding the java class.
I imagine a background thread is being started somewhere.