Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-1280

Java/Groovy mixed project Java `cannot find symbol` error

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 9.0
    • Fix Version/s: None
    • Component/s: None
    • Environment:
      Fedora Linux 28 64bit
      Linux Kernel 4.18.7
      Mate 1.20.3
      Memory: 8GiB
      Processor: Intel Core i5-6200U 2.30GHzx4

      Description

      When I have a mixed Groovy/Java project in netbeans, my Java classes are unable to import groovy classes in the same project. It shows them as errors in the import list. But when I run the build everything compiles and the code works.

      steps to reproduce:

      1. Create a single gradle project.
      2. Update build.gradle by adding `apply plugin: 'groovy'`
      3. Update build.gradle adding `compile 'org.codehaus.groovy:groovy:3.0.0-alpha-3'`
      4. Run clean/build
      5. Create `groovy` folder in the src/main/ directory
      6. Move Main java class into src/main/groovy (this way the groovy plugin will compile and run everything together without problem.)
      7. reload project so groovy shows up in the Projects view.
      8. Create a groovy class next to the Main java class.
      9. Create a simple method in groovy class.
      10. in the java class, instantiate the groovy class and run the method from it.

      At this point the Java class file will display the error `Cannot find symbol`. But if one runs the program it will compile and work just fine.

      The intended functionality works in other IDE, including NetBeans 8.2, however in 9 there is this problem.

       

      The attachments display the build.gradle file, the groovy and java class (java contains the errors) and a shot of the project structure.

        Attachments

        1. groovyClassWithSimpleMethod.png
          43 kB
          tor sorensen
        2. projectStructure.png
          18 kB
          tor sorensen
        3. javaClassWithError.png
          37 kB
          tor sorensen
        4. buildGradleShot.png
          115 kB
          tor sorensen

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              torbuntu tor sorensen
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: