[scala-tools] Re: Create simple Scala project results in syntax errors

View: New views
18 Messages — Rating Filter:   Alert me  

[scala-tools] Re: Create simple Scala project results in syntax errors

by Francois Armand-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <miles@...>:

> 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,

--
Francois Armand
http://fanf42.blogspot.com

Re: [scala-tools] Re: Create simple Scala project results in syntax errors

by Miles Sabin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Sep 1, 2009 at 2:58 PM, fanf42@...<fanf42@...> 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

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

[scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a small Maven project that uses

-- Scala library 2.8.0.r18462-b20090811081019,

-- scala-maven-plugin 2.11,

-- Spring 3.0.0.M4,

-- CGLIB 2.2,

-- AspectJ and AspectJ Weaver 1.6.5.

I want to use the load-time weaver so I can annotate classes with
Spring's @Configurable. Therefore, in my Spring XML, I say:

*

<context:load-time-weaver/>
<context:spring-configured/>

*

Compiling and building the project on the command line works fine, but
when running my program I get this:

*

Sep 2, 2009 7:03:57 PM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing
org.springframework.context.support.ClassPathXmlApplicationContext@10a2d64:
startup date [Wed Sep 02 19:03:57 CEST 2009]; root of context hierarchy
Sep 2, 2009 7:03:57 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[com/phrood/sack/sack.xml]
Sep 2, 2009 7:03:58 PM
org.springframework.context.weaving.DefaultContextLoadTimeWeaver
setBeanClassLoader
INFO: Found Spring's JVM agent for instrumentation
Sep 2, 2009 7:03:58 PM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@7a5a19:
defining beans
[org.springframework.context.weaving.AspectJWeavingEnabler#0,org.springframework.context.config.internalBeanConfigurerAspect,loadTimeWeaver,apple];
root of factory hierarchy
Sep 2, 2009 7:03:58 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: scala/collection/Iterator$$anon$3
org.aspectj.weaver.BCException: Whilst processing type
'Lscala/collection/Iterator$$anon$3;' - cannot cast the outer type to a
reference type.  Signature=Lscala/collection/Iterator$$anon;
toString()=scala.collection.Iterator$$anon
when processing type mungers
when weaving

        at
org.aspectj.weaver.AbstractReferenceTypeDelegate.getFormalTypeParametersFromOuterClass(AbstractReferenceTypeDelegate.java:105)
        at
org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectType.java:688)
        at
org.aspectj.weaver.bcel.BcelObjectType.getSuperclass(BcelObjectType.java:206)
        at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:821)
        at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:1391)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1223)
        at
org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:423)
        at
org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:286)
        at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:96)
        at
org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
        at
org.springframework.context.weaving.AspectJWeavingEnabler$AspectJClassBypassingClassFileTransformer.transform(AspectJWeavingEnabler.java:97)
        at
org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver$FilteringClassFileTransformer.transform(InstrumentationLoadTimeWeaver.java:181)
        at sun.instrument.TransformerManager.transform(Unknown Source)
        at sun.instrument.InstrumentationImpl.transform(Unknown Source)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at scala.collection.Iterator$.<init>(Iterator.scala:26)
        at scala.collection.Iterator$.<clinit>(Iterator.scala)
        at scala.package$.<init>(package.scala:15)
        at scala.package$.<clinit>(package.scala)
        at scala.Predef$.<init>(Predef.scala:65)
        at scala.Predef$.<clinit>(Predef.scala)
        at com.phrood.sack.Apple.<init>(Apple.scala:10)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:128)
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:69)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:931)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:883)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:528)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:716)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        at com.phrood.sack.Sack.run(Sack.scala:35)
Sep 2, 2009 7:03:58 PM org.aspectj.weaver.tools.Jdk14Trace info
INFO: Dumping to
c:\Users\phkoester\Data\phrood\sack\target\sack-1.0-beta-1-bin\.\ajcore.20090902.190358.678.txt
Sep 2, 2009 7:04:00 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: scala/util/DynamicVariable$$anon$1
org.aspectj.weaver.BCException: Whilst processing type
'Lscala/util/DynamicVariable$$anon$1;' - cannot cast the outer type to a
reference type.  Signature=Lscala/util/DynamicVariable$$anon;
toString()=scala.util.DynamicVariable$$anon
when processing type mungers
when weaving

        at
org.aspectj.weaver.AbstractReferenceTypeDelegate.getFormalTypeParametersFromOuterClass(AbstractReferenceTypeDelegate.java:105)
        at
org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectType.java:688)
        at
org.aspectj.weaver.bcel.BcelObjectType.getSuperclass(BcelObjectType.java:206)
        at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:821)
        at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:1391)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1223)
        at
org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:423)
        at
org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:286)
        at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:96)
        at
org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
        at
org.springframework.context.weaving.AspectJWeavingEnabler$AspectJClassBypassingClassFileTransformer.transform(AspectJWeavingEnabler.java:97)
        at
org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver$FilteringClassFileTransformer.transform(InstrumentationLoadTimeWeaver.java:181)
        at sun.instrument.TransformerManager.transform(Unknown Source)
        at sun.instrument.InstrumentationImpl.transform(Unknown Source)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at scala.Console$.<init>(Console.scala:60)
        at scala.Console$.<clinit>(Console.scala)
        at scala.Predef$.println(Predef.scala:162)
        at com.phrood.sack.Apple.<init>(Apple.scala:10)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:128)
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:69)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:931)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:883)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:528)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:716)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        at com.phrood.sack.Sack.run(Sack.scala:35)
Sep 2, 2009 7:04:00 PM org.aspectj.weaver.tools.Jdk14Trace info
INFO: Dumping to
c:\Users\phkoester\Data\phrood\sack\target\sack-1.0-beta-1-bin\.\ajcore.20090902.190400.347.txt

*

After that, things are uncertain. Whilst the @Configurable mechanism
does seem to work, my program might never return from other places,
keeping the CPU busy forever. Here is an example method where I observed
this:

*

/**
  * Using AspectJ weaving, this method never returns in my setup.
  */
private def run6 {
        println("-------------------- run6")
       
        val map1 = Map(1 -> "I", (2, "II"))
        for (i <- 1 until 3) {
                println(i + " -> " + map1(i))
        }
       
        val map2 = MutableMap[Int, String]()
        map2(1) = "Go to island."
        map2 += (2 -> "Find big X on ground.")
        map2 += ((3, "Dig."))
        for (i <- 1 to 3) {
                println(i + " -> " + map2(i))
        }
}

*

Noteworthily, everything compiles, builds and runs fine when I use one
of the nightly builds of the Scala IDE for Eclipse. This problem only
shows up when I build and run on the command line.

Does anyone have any experiences with using Scala in combination with
AspectJ's load-time weaver?

Regards
---Phil

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Linas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
>
> -- Scala library 2.8.0.r18462-b20090811081019,
>
> -- scala-maven-plugin 2.11,
>
> -- Spring 3.0.0.M4,
>
> -- CGLIB 2.2,
>
> -- AspectJ and AspectJ Weaver 1.6.5.
>
> I want to use the load-time weaver so I can annotate classes with
> Spring's @Configurable. Therefore, in my Spring XML, I say:
>
> *
>
> <context:load-time-weaver/>
> <context:spring-configured/>
>
> *
>
> Compiling and building the project on the command line works fine, but
> when running my program I get this:
>
> *
>
> Sep 2, 2009 7:03:57 PM
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing
> org.springframework.context.support.ClassPathXmlApplicationContext@10a2d64:
> startup date [Wed Sep 02 19:03:57 CEST 2009]; root of context hierarchy
> Sep 2, 2009 7:03:57 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [com/phrood/sack/sack.xml]
> Sep 2, 2009 7:03:58 PM
> org.springframework.context.weaving.DefaultContextLoadTimeWeaver
> setBeanClassLoader
> INFO: Found Spring's JVM agent for instrumentation
> Sep 2, 2009 7:03:58 PM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@7a5a19:
> defining beans
> [org.springframework.context.weaving.AspectJWeavingEnabler#0,org.springframework.context.config.internalBeanConfigurerAspect,loadTimeWeaver,apple];
> root of factory hierarchy
> Sep 2, 2009 7:03:58 PM org.aspectj.weaver.tools.Jdk14Trace error
> SEVERE: scala/collection/Iterator$$anon$3
> org.aspectj.weaver.BCException: Whilst processing type
> 'Lscala/collection/Iterator$$anon$3;' - cannot cast the outer type to a
> reference type.  Signature=Lscala/collection/Iterator$$anon;
> toString()=scala.collection.Iterator$$anon
> when processing type mungers
> when weaving
>
> at
> org.aspectj.weaver.AbstractReferenceTypeDelegate.getFormalTypeParametersFromOuterClass(AbstractReferenceTypeDelegate.java:105)
> at
> org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectType.java:688)
> at
> org.aspectj.weaver.bcel.BcelObjectType.getSuperclass(BcelObjectType.java:206)
> at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:821)
> at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:1391)
> at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1223)
> at
> org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:423)
> at
> org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:286)
> at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:96)
> at
> org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
> at
> org.springframework.context.weaving.AspectJWeavingEnabler$AspectJClassBypassingClassFileTransformer.transform(AspectJWeavingEnabler.java:97)
> at
> org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver$FilteringClassFileTransformer.transform(InstrumentationLoadTimeWeaver.java:181)
> at sun.instrument.TransformerManager.transform(Unknown Source)
> at sun.instrument.InstrumentationImpl.transform(Unknown Source)
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.access$000(Unknown Source)
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> at scala.collection.Iterator$.<init>(Iterator.scala:26)
> at scala.collection.Iterator$.<clinit>(Iterator.scala)
> at scala.package$.<init>(package.scala:15)
> at scala.package$.<clinit>(package.scala)
> at scala.Predef$.<init>(Predef.scala:65)
> at scala.Predef$.<clinit>(Predef.scala)
> at com.phrood.sack.Apple.<init>(Apple.scala:10)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
> Source)
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:128)
> at
> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:69)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:931)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:883)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
> at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
> at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:528)
> at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:716)
> at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
> at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
> at com.phrood.sack.Sack.run(Sack.scala:35)
> Sep 2, 2009 7:03:58 PM org.aspectj.weaver.tools.Jdk14Trace info
> INFO: Dumping to
> c:\Users\phkoester\Data\phrood\sack\target\sack-1.0-beta-1-bin\.\ajcore.20090902.190358.678.txt
> Sep 2, 2009 7:04:00 PM org.aspectj.weaver.tools.Jdk14Trace error
> SEVERE: scala/util/DynamicVariable$$anon$1
> org.aspectj.weaver.BCException: Whilst processing type
> 'Lscala/util/DynamicVariable$$anon$1;' - cannot cast the outer type to a
> reference type.  Signature=Lscala/util/DynamicVariable$$anon;
> toString()=scala.util.DynamicVariable$$anon
> when processing type mungers
> when weaving
>
> at
> org.aspectj.weaver.AbstractReferenceTypeDelegate.getFormalTypeParametersFromOuterClass(AbstractReferenceTypeDelegate.java:105)
> at
> org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectType.java:688)
> at
> org.aspectj.weaver.bcel.BcelObjectType.getSuperclass(BcelObjectType.java:206)
> at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:821)
> at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:1391)
> at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1223)
> at
> org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:423)
> at
> org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:286)
> at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:96)
> at
> org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:52)
> at
> org.springframework.context.weaving.AspectJWeavingEnabler$AspectJClassBypassingClassFileTransformer.transform(AspectJWeavingEnabler.java:97)
> at
> org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver$FilteringClassFileTransformer.transform(InstrumentationLoadTimeWeaver.java:181)
> at sun.instrument.TransformerManager.transform(Unknown Source)
> at sun.instrument.InstrumentationImpl.transform(Unknown Source)
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.defineClass(Unknown Source)
> at java.net.URLClassLoader.access$000(Unknown Source)
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> at scala.Console$.<init>(Console.scala:60)
> at scala.Console$.<clinit>(Console.scala)
> at scala.Predef$.println(Predef.scala:162)
> at com.phrood.sack.Apple.<init>(Apple.scala:10)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
> Source)
> at java.lang.reflect.Constructor.newInstance(Unknown Source)
> at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:128)
> at
> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:69)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:931)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:883)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289)
> at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188)
> at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:528)
> at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:716)
> at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
> at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
> at com.phrood.sack.Sack.run(Sack.scala:35)
> Sep 2, 2009 7:04:00 PM org.aspectj.weaver.tools.Jdk14Trace info
> INFO: Dumping to
> c:\Users\phkoester\Data\phrood\sack\target\sack-1.0-beta-1-bin\.\ajcore.20090902.190400.347.txt
>
> *
>
> After that, things are uncertain. Whilst the @Configurable mechanism
> does seem to work, my program might never return from other places,
> keeping the CPU busy forever. Here is an example method where I observed
> this:
>
> *
>
> /**
>   * Using AspectJ weaving, this method never returns in my setup.
>   */
> private def run6 {
> println("-------------------- run6")
>
> val map1 = Map(1 -> "I", (2, "II"))
> for (i <- 1 until 3) {
> println(i + " -> " + map1(i))
> }
>
> val map2 = MutableMap[Int, String]()
> map2(1) = "Go to island."
> map2 += (2 -> "Find big X on ground.")
> map2 += ((3, "Dig."))
> for (i <- 1 to 3) {
> println(i + " -> " + map2(i))
> }
> }
>
> *
>
> Noteworthily, everything compiles, builds and runs fine when I use one
> of the nightly builds of the Scala IDE for Eclipse. This problem only
> shows up when I build and run on the command line.
>
> Does anyone have any experiences with using Scala in combination with
> AspectJ's load-time weaver?
>
> Regards
> ---Phil


Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Linas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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 ...

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Miles Sabin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Sep 2, 2009 at 7:20 PM, Philip Köster<philip.koester@...> 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

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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?

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Miles Sabin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Sep 2, 2009 at 7:54 PM, Philip Köster<philip.koester@...> 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

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Linas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?
>



Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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 ... :)

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Miles Sabin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Sep 2, 2009 at 8:23 PM, Philip Köster<philip.koester@...> 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

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Pedro-45 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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<philip.koester@...> 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?
>

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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?

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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?

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by phkoester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: [scala-tools] maven-scala-plugin + Spring + AspectJ Weaving is Funky

by Linas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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