scala - class SomeClass in package x cannot be accessed in com.a.y.x -


i'm attempting un-spring ioc several java classes , load them directly in scala code. naturally i'm finding there name space conflicts between package like

com.a.x.someclass 

and

com.a.y.x.someclass 

i've tried using import name space resolvers like

import com.a.y.x.{ someclass => yyysomeclass } import com.a.x{ someclass => xxxsomeclass } 

that cleans imports, referring classes later in classes show error hovers in typesafe scalaide, , after clean compilations.

when compile gradle scala plugin, or via typesafe scalaide scala 2.10.2 or 2.10.3, following type of un-useful error messages:

class someclass in package x cannot accessed in com.a.y.x 

the problem occurs if try use class com.a.y.x doesn't have name space conflict. if try of scalac flags, i've been able warning out that's different ( during typer stage ):

class someclass in package x cannot accessed in y.this.x 

i'd know if there's way expand first package reference. i'm having trouble setting eclipse project debug scalac compiler , haven't found scalac flag adds useful information error.

the error occurs when either try ctx.getbean("someclass").asinstanceof[xxxsomeclass] or new xxxsomeclass.

the this reference warning makes me think there's object confusion going on. don't think it's classpath issue in larger project i'm working on because removing 1 jar removes ability resolve imports, can't reproduce simple example classes in separate project.

a little more information on java classes - different, conflicting java packages in separate jars compiled 1.6 flavor of java. top level, public classes although 2 singletons private constructors , corresponding public static getinstance() methods.

it access error. think poor error message. java compiled separately , accessed jar files. hadn't paid enough attention package private nature of classes wanted instantiate( had seen "public" in front of of them , not checked of them ). name space collisions red-herring in case , don't affect output of error message.

in cases, there public interfaces can use instead little bit of spring-glue instantiate objects , load them scala class.

the scalac error message have been more helpful if had form:

class someclass in package com.a.y.x cannot accessed in totally.unrelated 

where first package reference java class's package , trailing package package of scala class trying instantiate java class.

to recap - java class like:

package com.a.y.x.someclass  class someclass extends someotherclass implements someinterface 

and needs like:

package com.a.y.x.someclass  public class someclass extends someotherclass implements someinterface 

to not these access errors.

since have more control of scala here, on whim tried changing package of scala class totally.unrelated com.a.x.y compiles cleanly. might guess, merely defers error run time error -> java.lang.illegalaccesserror. however, illegalaccesserror java has description/package order think should happen in compilation error scalac:

...java.lang.illegalaccesserror: tried access class com.a.y.x.someclass class s.trouble$delayedinit$body 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -