This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 246723 - IDE indicates errors in source and run / debug fails in IDE. But "clean and build" compiles successfully and runs from command line or Glassfish 4.
Summary: IDE indicates errors in source and run / debug fails in IDE. But "clean and ...
Status: NEW
Alias: None
Product: contrib
Classification: Unclassified
Component: Scala (show other bugs)
Version: 8.0
Hardware: PC Linux
: P1 normal with 1 vote (vote)
Assignee: _ dcaoyuan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-27 10:02 UTC by pizzavore
Modified: 2015-05-15 11:15 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Zip file containing example projects and screenshots. (6.39 MB, application/x-zip-compressed)
2014-08-27 10:02 UTC, pizzavore
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pizzavore 2014-08-27 10:02:54 UTC
Created attachment 148921 [details]
Zip file containing example projects and screenshots.

PROBLEM:  I have a project which includes a .jar file that compiles and builds correctly, and runs correctly if executed outside the Netbeans IDE, such as on the command-line.  But it fails to execute properly within the IDE.

It does build correctly inside the IDE, BUT the editor still indicates there are errors in the source code.

When attempting to execute the code within the IDE, Netbeans warns that the code has errors (even though it does not) and asks if you wish to run the project anyway.  If run, it throws exceptions.  However, the same code executes perfectly when run externally from the command line with using:

   java -jar XXXXXX.jar


I have attached screenshots and three very simple projects which illustrate this problem.

I discovered this issue after many days of wrestling with Scala using the NBScala plugin, but I am convinced this is a problem internal to the Netbeans IDE since the jars are all valid and execute correctly externally.

I hope this will help someone fix the issue quickly as this will rapidly become a showstopper for us using Netbeans.  And I'm a huge fan of Netbeans, since version 3.5.

Also, I would love to see Netbeans become the leading IDE for Scala development.

Example Code:

ScalaNetbeansTest.jar:  (Scala source):
----------------------

Account.scala:

    package src

    import scala.collection.mutable._;
    import scala.collection._;
    import scala.collection.JavaConversions._;
    import scala.collection.JavaConverters._;

    class Account {

      val testScalaList = List("ScalaList One", "ScalaList Two", "ScalaList Three");
      var testJavaList : java.util.ArrayList[String] = new java.util.ArrayList[String]();

      def initialize() = {
        testJavaList.add("JavaList One");
        testJavaList.add("JavaList Two");
        testJavaList.add("JavaList Three");
      }
      initialize();

      def TEST_getJavaList() : java.util.List[String] = {
        testJavaList;
      }

      def TEST_getScalaList(): List[String] = {
        testScalaList;
      }

    }

JavaScalaNetbeansTest.jar:
--------------------------

Person.java:

package java_src;

import src.Account;
import java.util.*;

public class Person {

    private Account account = new Account();

    public void runAll() {
        someFunction1();
        someFunction2();
        someFunction3();
        someFunction4();
    }

    public void someFunction1() {
        System.out.println("someFunction1");

        //  IDE indicates error:  Cannot find symbol: ".TEST_getScalaList" for variable "account" of type Account.
        ArrayList<String> nums = new ArrayList<>(scala.collection.JavaConversions.asJavaCollection(account.TEST_getScalaList()));
        for (String num : nums) {
            System.out.println("Num: " + num);
        }
    }

    public void someFunction2() {
        System.out.println("someFunction2");

        //  IDE indicates error:  Cannot find symbol: ".TEST_getScalaList" for variable "account" of type Account.
        ArrayList<String> nums = new ArrayList<>(account.TEST_getJavaList());
        for (String num : nums) {
            System.out.println("Num: " + num);
        }
    }

    public void someFunction3() {
        System.out.println("someFunction3");

        //  IDE indicates error:  the type of "testScalaList()" is erroneous
        ArrayList<String> nums = new ArrayList<>(scala.collection.JavaConversions.asJavaCollection(account.testScalaList()));
        for (String num : nums) {
            System.out.println("Num: " + num);
        }
    }

    public void someFunction4() {
        System.out.println("someFunction4");

        //  IDE indicates error:  the type of "testJavaList()" is erroneous
        ArrayList<String> nums = new ArrayList<>(account.testJavaList());
        for (String num : nums) {
            System.out.println("Num: " + num);
        }
    }
}



JavaScalaNetbeansTestApp.jar:  (Simple Test Client)
------------------------------

JavaScalaNetbeansTestApp.java:

package javascalanetbeanstestapp;

import java_src.Person;

public class JavaScalaNetbeansTestApp {
    public static void main(String[] args) {
        Person person = new Person();
        person.runAll();
    }
}

If I run the project despite the supposed compilation errors, Netbeans produces the following results:

    run:
    Exception in thread "main" java.lang.ClassFormatError: Method "<error>" in class src/Account has illegal signature "()Ljava/lang/Object;"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java_src.Person.<init>(Person.java:10)
        at javascalanetbeanstestapp.JavaScalaNetbeansTestApp.main(JavaScalaNetbeansTestApp.java:15)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 4 seconds)


However, if run on the command-line, the program executes correctly with the following output:

    $ java -jar JavaScalaNetbeansTestApp.jar
    someFunction1
    Num: ScalaList One
    Num: ScalaList Two
    Num: ScalaList Three
    someFunction2
    Num: JavaList One
    Num: JavaList Two
    Num: JavaList Three
    someFunction3
    Num: ScalaList One
    Num: ScalaList Two
    Num: ScalaList Three
    someFunction4
    Num: JavaList One
    Num: JavaList Two
    Num: JavaList Three


Below is my Netbeans version info running on Ubuntu 12.04:

Product Version: NetBeans IDE 8.0 (Build 201403101706)
Updates: NetBeans IDE is updated to version NetBeans 8.0 Patch 2
Java: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_11-b12
System: Linux version 3.5.0-48-generic running on amd64; UTF-8; en_US (nb)
User directory: /home/paul/.netbeans/8.0
Cache directory: /home/paul/.cache/netbeans/8.0

Thanks,
Paul
Comment 1 Tomas Stupka 2015-05-15 11:15:10 UTC
please evaluate