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 233417 - Cannot run Java file with groovy reference inside
Summary: Cannot run Java file with groovy reference inside
Status: VERIFIED FIXED
Alias: None
Product: groovy
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.4
Hardware: PC Linux
: P2 normal (vote)
Assignee: Martin Janicek
URL: http://groovy.codehaus.org/The+groovy...
Keywords: 7.4_HR_FIX
: 234936 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-25 11:55 UTC by Vladimir Riha
Modified: 2013-09-19 16:01 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (68.86 KB, text/x-log)
2013-07-25 11:55 UTC, Vladimir Riha
Details
Patch with possible solution (3.03 KB, patch)
2013-09-02 14:24 UTC, Martin Janicek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2013-07-25 11:55:59 UTC
Created attachment 137786 [details]
IDE log

Please try:
- create Java Application, all default
- create a new Groovy class "Foo" in the default existing package
- in JavaApplication.java, paste this into main() method

Foo f = new Foo();

- run JavaApplication.java file




=> run fails with following output (running project is OK):


ant -f /home/vriha/NetBeansProjects/a/JavaApplication -Djavac.includes=javaapplication/JavaApplication.java -Drun.class=javaapplication.JavaApplication -Dnb.internal.action.name=run.single run-single
init:
deps-jar:
Created dir: /home/vriha/NetBeansProjects/a/JavaApplication/build
Updating property file: /home/vriha/NetBeansProjects/a/JavaApplication/build/built-jar.properties
Created dir: /home/vriha/NetBeansProjects/a/JavaApplication/build/classes
Created dir: /home/vriha/NetBeansProjects/a/JavaApplication/build/empty
Compiling 1 source file to /home/vriha/NetBeansProjects/a/JavaApplication/build/classes
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Compile error during compilation with javac.
/ho
me/vriha/NetBeansProjects/a/JavaApplication/src/javaapplication/JavaApplication.java:18: error: cannot find symbol
        Foo f
 = new Foo();
        ^
  symbol:   class Foo
  location: class JavaApplication
/home/vriha/NetBeansProjects/a/JavaApplication/s
rc/javaapplication/JavaApplication.java:18: error: cannot find symbol
        Foo f = new Foo();
                    ^
  symbol:
   class Foo
  location: class JavaApplication
2 errors


1 error

/home/vriha/NetBeansProjects/a/JavaApplication/nbproject/build-impl.xml:944: The following error occurred while executing this line:
/home/vriha/NetBeansProjects/a/JavaApplication/nbproject/groovy-build.xml:26: Forked groovyc returned error code: 1
BUILD FAILED (total time: 2 seconds)




Product Version: NetBeans IDE Dev (Build 201307242300)
Java: 1.7.0_40-ea; Java HotSpot(TM) Client VM 24.0-b52
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b33
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 1 Martin Janicek 2013-08-22 12:08:11 UTC
I think this is most probably the same problem as issue 233416 (at least I do not see any way how to evaluate-fix it on the Groovy side). Closing the issue as duplicate and if the problem persist after the 233416 fix, I'll take a look again.
Comment 2 Martin Janicek 2013-08-22 12:08:23 UTC

*** This bug has been marked as a duplicate of bug 233416 ***
Comment 3 Vladimir Riha 2013-08-22 12:11:25 UTC
OK, I'll try it again once the issue will be fixed. Thank you for evaluation.
Comment 4 Vladimir Riha 2013-09-02 11:44:38 UTC
Martine, unfortunately it is still reproducible although the issue 233416 is fixed. Thank you


Product Version: NetBeans IDE Dev (Build 201309020001)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b39
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 5 Martin Janicek 2013-09-02 11:46:33 UTC
Ok, thanks. I'll take a look at it..
Comment 6 Vladimir Riha 2013-09-02 11:50:12 UTC
*** Bug 234936 has been marked as a duplicate of this bug. ***
Comment 7 Martin Janicek 2013-09-02 14:24:51 UTC
Created attachment 139581 [details]
Patch with possible solution

Patch of possible solution. I need to evaluate further if it's completely safe to make such change.
Comment 8 Martin Janicek 2013-09-03 14:39:23 UTC
Well this is awesome, such thing obviously never worked (fails also in 7.3 where the Run File action were implemented for Groovy files) because the build script is including only the source file where the Run action is performed and thus groovy compiler cannot see the rest of the source directory. Same failure is there also when using two groovy files or also for two java files (with groovy activated within that project).

On the other hand when running the whole project, the "includes" attribute contains "**" value and thus everything works as expected.

Proposed solution just removes "includes" attribute from groovyc Ant task which should be safe and correct. Current usage of @{includes} attribute was just incorrect from the beginning. I'll push the changes soon..

Few related links:
http://groovy.codehaus.org/The+groovyc+Ant+Task
http://ant.apache.org/manual/Tasks/javac.html#srcdirnote
Comment 9 Martin Janicek 2013-09-03 14:44:26 UTC
Fixed by change-set: web-main #d67b6a86adca
Comment 10 Vladimir Riha 2013-09-03 14:54:27 UTC
None one has the "clever" idea to run a single file as I did :) Thanks Martine. 

After offline discussion marking as HR_FIX_CAND so it gets into 7.4
Comment 11 Vladimir Riha 2013-09-04 08:44:35 UTC
Verified in trunk, please continue with integration to release74 as described
in [1]. Thank you


[1] http://wiki.netbeans.org/NetBeans_74_HighResistance



Product Version: NetBeans IDE Dev (Build 201309040001)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b39
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 12 Martin Janicek 2013-09-04 11:30:53 UTC
Martine, may I ask you for review?
Comment 13 Martin Fousek 2013-09-04 12:01:31 UTC
(In reply to Martin Janicek from comment #12)
> Martine, may I ask you for review?

The patch looks safe.
Comment 14 Martin Janicek 2013-09-05 11:13:18 UTC
releases #a25ef81941bf
Comment 15 Vladimir Riha 2013-09-19 16:01:09 UTC
Verified in RC1

Product Version: NetBeans IDE 7.4 RC1 (Build 201309162201)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)