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

Re: Create simple Scala project results in syntax errors

17 replies
fanf
Joined: 2009-03-17,
User offline. Last seen 2 years 30 weeks ago.

Hello,

I just joined the list, so I'm sorry to break the thread view about
"Create simple Scala project results in syntax errors " from Lars
Vogel-2, but I would to add a better solution.

2009/8/25 Miles Sabin :
> On Mon, Aug 24, 2009 at 11:02 PM, Lars Vogel wrote:
>> The JDT weaving remains disabled no matter how often I try to
>> activate this. I have not found information on
>> http://www.scala-lang.org/node/94 why this could be happen.
>>
>> I use Eclipse 3.5 and the Scala plugin 2.7.5.final.
>>
>> Any advice?
>
> Getting JDT weaving enabled is essential ... there's no point
> attempting anything until that's fixed.
[...]

I, too, had this problem : on a fresh eclipse installation, everything
worked great, and someday I installed some other eclipse plugins and
after the restart, weaving was disabled and won't be enable anymore.

The solution was to close Eclipse, edit the JDT config file by hand, and
set the JDT weaving to true:
----
% vim
eclipse-3.5/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
----
Edit the line that begins with
"org.eclipse.equinox.weaving.aspectj,1.0.0" to replace the false at the
end by "true"

More info may be found here : http://wiki.eclipse.org/JDT_weaving_features

Hope it helps,

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Re: Create simple Scala project results in syntax errors

On Tue, Sep 1, 2009 at 2:58 PM, fanf42@gmail.com wrote:
> I, too, had this problem : on a fresh eclipse installation, everything
> worked great, and someday I installed some other eclipse plugins and
> after the restart, weaving was disabled and won't be enable anymore.
>
> The solution was to close Eclipse, edit the JDT config file by hand, and
> set the JDT weaving to true:
> ----
> % vim
> eclipse-3.5/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
> ----
> Edit the line that begins with
> "org.eclipse.equinox.weaving.aspectj,1.0.0" to replace the false at the
> end by "true"
>
> More info may be found here : http://wiki.eclipse.org/JDT_weaving_features

This is a good suggestion, but I recommend working through the other
troubleshooting steps *before* attempting manual edits of internal
Equinox configuration files.

I've only needed to make this edit in the context of a read-only
Eclipse installation with disjoint configuration area.

Cheers,

Miles

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
maven-scala-plugin + Spring + AspectJ Weaving is Funky

I have a small Maven project that uses

Linas
Joined: 2009-09-02,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

That's because currently aspectj weaver tries find outer class of inner
class by dropping one segment from inner class name after last "$"
symbol. This works with java classes since javac composes inner class
names as "Outer$Inner", but does not work with scala, since scalac does
not follow this convention.

I submitted a relevant patch to aspectj bugzilla
https://bugs.eclipse.org/bugs/show_bug.cgi?id=288064 , you can use it to
compile your own patched weaver or wait while aspectj team gets around
to incorporate it into their code.

Linas.

On Wed, 2009-09-02 at 19:16 +0200, Philip Köster wrote:
> I have a small Maven project that uses
>

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

Dear Linas,

> That's because currently aspectj weaver tries find outer class of inner
> class by dropping one segment from inner class name after last "$"
> symbol. This works with java classes since javac composes inner class
> names as "Outer$Inner", but does not work with scala, since scalac does
> not follow this convention.

thanks a lot for your quick and and illuminative answer. It is a joy to
be on this list indeed.

I'm not familiar with this `diff´and `patch´ stuff, and I don't think I
want to build the weaver on my own ... So do you think there will be a
new weaver jar any time soon, on one of the public Maven repos, or on
any other repo? Where should I keep watching?

What strikes me is that everything works fine with Miles Sabin's Eclipse
IDE. Why is that? I even had "Miles" compile everything and, on the
command line, changed the Scala library 2.8.0.r18462-b20090811081019 to
2.8.0.r18604-b20090830020201, which is the version that Miles uses
internally, but to no avail.

---Phil

Linas
Joined: 2009-09-02,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

Sorry, I'm new to scala and aspectj stuff myself so I can't predict
anything about their processes.

Maybe Miles Sabin can shed more light or advice on the situation.

Linas.

On Wed, 2009-09-02 at 19:42 +0200, Philip Köster wrote:
> Dear Linas,
>
> > That's because currently aspectj weaver tries find outer class of inner
> > class by dropping one segment from inner class name after last "$"
> > symbol. This works with java classes since javac composes inner class
> > names as "Outer$Inner", but does not work with scala, since scalac does
> > not follow this convention.
>
> thanks a lot for your quick and and illuminative answer. It is a joy to
> be on this list indeed.
>
> I'm not familiar with this `diff´and `patch´ stuff, and I don't think I
> want to build the weaver on my own ... So do you think there will be a
> new weaver jar any time soon, on one of the public Maven repos, or on
> any other repo? Where should I keep watching?
>
> What strikes me is that everything works fine with Miles Sabin's Eclipse
> IDE. Why is that? I even had "Miles" compile everything and, on the
> command line, changed the Scala library 2.8.0.r18462-b20090811081019 to
> 2.8.0.r18604-b20090830020201, which is the version that Miles uses
> internally, but to no avail.
>
> ---Phil

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

> Sorry, I'm new to scala and aspectj stuff myself so I can't predict
> anything about their processes.
>
> Maybe Miles Sabin can shed more light or advice on the situation.

I suspect it's nothing to do with the Scala IDE but with the
`aspectjweaver.jar´ that is bundled with Eclipse. It must be a later
version than is available on the public Maven repos. I'll check that out ...

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

On Wed, Sep 2, 2009 at 7:20 PM, Philip Köster wrote:
> I suspect it's nothing to do with the Scala IDE but with the
> `aspectjweaver.jar´ that is bundled with Eclipse. It must be a later version
> than is available on the public Maven repos. I'll check that out ...

It's a bug in the aspect weaver, certainly ... thanks Linas very much
for finding and fixing it!

Nevertheless, the aspect weaver ships as a component of the Scala IDE
and needs to be refreshed when the AspectJ people make an updated
release ... I'd be very grateful if someone (Linas?) could keep an eye
on that and ping me (either directly or via the Scala Trac) when it's
available.

Linas, out of interest, with your patch applied, can the aspect weaver
cope with all scalac generated bytecode? I was under the impression
that there was also a problem with early initializers?

Is anyone experimenting with combined Scala/Java/AspectJ projects with
ADJT and the Scala tooling both enabled on the project? If so, how's
it working out?

Cheers,

Miles

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

> Is anyone experimenting with combined Scala/Java/AspectJ projects with
> ADJT and the Scala tooling both enabled on the project? If so, how's
> it working out?

Yes I am. :) I mix Java and Scala files at will, am using AJDT (through
Spring), everything in one project. Things work perfectly with your IDE,
Miles, but not on the command line.

I just replaced the 1.6.5 flavors of `aspectjrt.jar' and
`aspectjweaver.jar' with the ones I found in the Eclipse 3.5.0 tree, but
that didn't solve the problem.

Are you using any special versions of AspectJ, with different file names
possibly, for your IDE, Miles?

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

On Wed, Sep 2, 2009 at 7:54 PM, Philip Köster wrote:
>> Is anyone experimenting with combined Scala/Java/AspectJ projects with
>> ADJT and the Scala tooling both enabled on the project? If so, how's
>> it working out?
>
> Yes I am. :) I mix Java and Scala files at will, am using AJDT (through
> Spring), everything in one project. Things work perfectly with your IDE,
> Miles,

Cool!

> but not on the command line.

Not so cool ...

> I just replaced the 1.6.5 flavors of `aspectjrt.jar' and `aspectjweaver.jar'
> with the ones I found in the Eclipse 3.5.0 tree, but that didn't solve the
> problem.
>
> Are you using any special versions of AspectJ, with different file names
> possibly, for your IDE, Miles?

No, nothing special. Trunk is matched with AJDT 2.0.0 and 2.7.5.final
is matched with AJDT 1.6.4.

Cheers,

Miles

Linas
Joined: 2009-09-02,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

No idea. If the problem was related to inner class naming and scalac
correctly generates InnerClasses attribute for every inner class it
produces, then my patch should help, otherwise it will not :).

Linas.

On Wed, 2009-09-02 at 19:44 +0100, Miles Sabin wrote:
...
>
> Linas, out of interest, with your patch applied, can the aspect weaver
> cope with all scalac generated bytecode? I was under the impression
> that there was also a problem with early initializers?
>

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

> No, nothing special. Trunk is matched with AJDT 2.0.0 and 2.7.5.final
> is matched with AJDT 1.6.4.

I just checked what I installed and saw that I am actually using AJDT
2.0.1.e35x-20090828-1200. Now that's a lot of version madness for one
beautiful late-summer evening ... I guess that's the price you pay if
you stick your nose into the bleeding edge of things. I could not
recommend using any of the packages involved for commercial purposes
today, but well, I guess this is the software I might be using tomorrow.
I'm just trying to get the most out of my home research experiments.

Do you have any clue or far anticipation why everything is fine with
your IDE but not when I try to build my stuff on the cmd line?

I also noticed that it does make a subtle difference if you change the
order of the builders in an Eclipse project. I found out that it is less
troublesome to have the Maven Project Builder *before* the Scala
Builder, but don't ask me why ... :)

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

On Wed, Sep 2, 2009 at 8:23 PM, Philip Köster wrote:
> Do you have any clue or far anticipation why everything is fine with your
> IDE but not when I try to build my stuff on the cmd line?

It looks like the version of the AspectJ that you're using from the
command line is older than the one bundled with recent AJDT releases
... I would guess that upgrading to the most recent AspectJ release
will help.

If not then, sorry, no idea beyond what Linas has already commented.

Cheers,

Miles

Pedro Furlanetto
Joined: 2009-08-19,
User offline. Last seen 2 years 34 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

I couldn't make it work at all. Seems like scala don't get weaved at
all. What kind of weaving are you using?

By the way, a little off-topic curiosity, if you are using load-time
weaving is it really necessary to build against the aspectjrt? I mean,
wouldn't it be possible to build the scala/java normally and only the
aspects using the aspect stuff?

On Wed, Sep 2, 2009 at 3:54 PM, Philip Köster wrote:
>> Is anyone experimenting with combined Scala/Java/AspectJ projects with
>> ADJT and the Scala tooling both enabled on the project? If so, how's
>> it working out?
>
> Yes I am. :) I mix Java and Scala files at will, am using AJDT (through
> Spring), everything in one project. Things work perfectly with your IDE,
> Miles, but not on the command line.
>
> I just replaced the 1.6.5 flavors of `aspectjrt.jar' and `aspectjweaver.jar'
> with the ones I found in the Eclipse 3.5.0 tree, but that didn't solve the
> problem.
>
> Are you using any special versions of AspectJ, with different file names
> possibly, for your IDE, Miles?
>

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

> I couldn't make it work at all. Seems like scala don't get weaved at
> all. What kind of weaving are you using?

The Maven artifact is `org.aspectj:aspectjweaver', version 1.6.5.

> By the way, a little off-topic curiosity, if you are using load-time
> weaving is it really necessary to build against the aspectjrt?

Yes you're right---it seems the the `aspectjrt' artifact really isn't
needed. The weaver is not dependent on the AspectJ run-time and can run
on its own; thank you.

Still I'm stuck here. I can't get my program to run on the command line.
Again, in Eclipse everything is fine. This really bugs me because it
effectively means I cannot use any Scala code together with my existing
Java apps. Pity.

I still don't understand the problem: if it's really the name mangling
and the dollar sign `$' to cause the trouble, which seems plausible,
then why don't I get this error in the Eclipse environment?

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

> I couldn't make it work at all. Seems like scala don't get weaved at
> all.

I think it is. Here is a snippet of mine

@Configurable
class Bean {
private var _soil: Soil = null

def soil: Soil = _soil

@Resource
def soil_=(soil: Soil) { _soil = soil }
}

private def run5 {
println("-------------------- run5")

println(toReadableString)
val bean = new Bean
println(bean.soil.toReadableString)
}

Here, a bean of type `Soil' is instantiated through Spring. I create a
new `Bean' using `new', where the `@Configurable' annotation has the
effect that `soil_=(Soil)' is called. Running `run5' does not yield an
NPE but behaves as desired. I take this as a proff that Scala does get
weaved here.

What's more, I am surprised that the assignment operator (or whatever it
is called in Scala) is correctly found and called here. Does this mean
that Spring is Scala-aware? Or is there a hidden `setSoil(Soil)' method
in the bytecode?

phkoester
Joined: 2009-08-23,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

Linas wrote:

> That's because currently aspectj weaver tries find outer class of inner
> class by dropping one segment from inner class name after last "$"
> symbol. This works with java classes since javac composes inner class
> names as "Outer$Inner", but does not work with scala, since scalac does
> not follow this convention.
>
> I submitted a relevant patch to aspectj bugzilla
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=288064 , you can use it to
> compile your own patched weaver or wait while aspectj team gets around
> to incorporate it into their code.

Dear Linas,

from where did you check out the weaver source? From
`.../cvsroot/tools/HEAD/org.aspectj/modules/weaver' or from
`.../cvsroot/tools/HEAD/org.aspectj/modules/weaver5' or from a
completely different location?

I expected to see a `pom.xml' next to the `.project' file, but there
only seem to be Ant scripts.

Anyway, I'm uncertain about the correct SCM address.

Second question: Naturally, I don't want to change any sources without
talking to the guy or girl maintaining them. Whom should I contact, and
how, to suggest changes to the source?

Cheers
---Phil

Linas
Joined: 2009-09-02,
User offline. Last seen 42 years 45 weeks ago.
Re: maven-scala-plugin + Spring + AspectJ Weaving is Funky

I checked out everything under "modules". "weaver" project contains the
code that is actually used.

You can talk with the aspectj developers through the mailing list
(https://dev.eclipse.org/mailman/listinfo/ajdt-dev) and submit patches
through bugzilla
(http://www.eclipse.org/aspectj/doc/released/faq.php#q:bugreports).

Linas.

On Wed, 2009-10-07 at 07:09 +0200, Philip Köster wrote:
> Linas wrote:
>
> > That's because currently aspectj weaver tries find outer class of inner
> > class by dropping one segment from inner class name after last "$"
> > symbol. This works with java classes since javac composes inner class
> > names as "Outer$Inner", but does not work with scala, since scalac does
> > not follow this convention.
> >
> > I submitted a relevant patch to aspectj bugzilla
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=288064 , you can use it to
> > compile your own patched weaver or wait while aspectj team gets around
> > to incorporate it into their code.
>
> Dear Linas,
>
> from where did you check out the weaver source? From
> `.../cvsroot/tools/HEAD/org.aspectj/modules/weaver' or from
> `.../cvsroot/tools/HEAD/org.aspectj/modules/weaver5' or from a
> completely different location?
>
> I expected to see a `pom.xml' next to the `.project' file, but there
> only seem to be Ant scripts.
>
> Anyway, I'm uncertain about the correct SCM address.
>
> Second question: Naturally, I don't want to change any sources without
> talking to the guy or girl maintaining them. Whom should I contact, and
> how, to suggest changes to the source?
>
> Cheers
> ---Phil

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