import not finding Java Class in same project

sadfsad
I have a Scala class that imports from   
      a) a (java) interface in same package
       b) a java core library (HashMap)
       c) 3rd party jar

Both b) and c) are working,  but not a).   The code and the error message are shown in attached screenshot.

What is the missing IJ/scalascalaJavaImportError.JPG project configuration causing this problem ?

5 comments

As an experiment I unchecked "Compile Scala classes first" in Settings | Compiler | Scala.  That made no difference.

0

Is editor shows imported Java Interface as green? Or it's red? If it's green then it seems that all dependencies are ok, if it's not, then you should manage your dependencies.
If scala compiler works first, then it will compile Java and Scala files together, but creating appropriate class files only for Scala files, then Java compiler build class files for Java files.
That compiler which you use is same as if you don't use IDE and call compiler explicitly, so you can check, it can be scala compiler bug, then you need to reduce testcase for reporting this.
Anyway it's also possible that it's plugin bug, then I need more information (in our plugin code we use Java and Scala code, and such compilation works), for example small project with two files, which reproduces this problem.

Best regards,
Alexander Podkhalyuzin.

0

>> Is editor shows imported Java Interface as green? Or it's red?

The screenshot is included in this post - shows it is gray-ish  - so why need to ask?   Both the screenshot and my prose both say the IDE is  happy with the code.  It's the compiler not happy.

In terms of a sample code:  the code you see in screenshot is all of it - I commented out the entire body of the class.  It is just a Scala class importing a java class in the same project.  If it works for you, then there is a difference in our configurations.  So then, I don't know what the difference is (i.e. why should any configuration cause a java class in same project not to be accessible in scala).

In any case here it is

package com.mycompany.server

import com.mycompany.server.TWDatastoreService       // This import causes error in compiler (but not in IDE)

import com.google.appengine.api.datastore._

import java.util.HashMap

import org.exist.management.impl.Database

import org.xmldb.api._

import org.xmldb.api.modules._

import org.xmldb.api.base._

import org.xmldb.api.base.ResourceSet

/**

* ExistDataService

*

* Created by SBoesch on Oct 17, 2010 at 9:43:46 PM

*

* Copyright (c) mycompany.com 2010. All rights reserved.

*/

class ExistDataService /* extends TWDatastoreService */ {

// Bunch of commented out code
}
0

Question was: is IDE happy about commented extends list /* extends TWDatastoreService */ if it's uncommented. IDE will be happy with import list, until you enable advanced highlighting (which is disabled by default, because of many bugs like: good code is red), which you can enable using Alt+Ctrl+Shift+E shortcut.
My guess about this problem:
1. ExistDataService and TWDatastoreService in same package, but in different modules.
2. There is no dependency in right direction between this modules
If it's true, then described behavior is expected.
But it's too simple to be true, and moreover I don't know another explanation. More information I meant about location of file TWDatastoreService (modules, module dependency) and IDEA and Scala plugin versions. I tried many configurations, and described behavior only if there is no dependency between modules in right direction.

Best regards,
Alexander Podkhalyuzin.

0

Oh I see.  I had needed to comment out the "extends" clause in order to get the rest of my project to compile (and do my work). I neglected to uncomment it for this post. So that explains your question.    

To reply back:  when I had previously had the  "extends" uncommented the behavior was as described: the syntax highlighter (editor) is happy but the compiler gave an error about unknown symbol  TWDataService .

There is only one module in my project and all of the code both java and scala are in it.


I am in 9.0.3 IJ  and scala version is 2.8.0

But here is an update:  this class is now compiling. I do not know why.  Same code.  I did change some unrelated maven dependencies (for mongodb which has nothing to do with this class).

So there is some intermittent bug in discrepenacy between IDE and compiler.. but for now as long it is not biting me at this moment.. i just move on .
0

Please sign in to leave a comment.