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 250858 - javac -parameters Option and "Compile on save" in Maven projects
Summary: javac -parameters Option and "Compile on save" in Maven projects
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0.2
Hardware: Macintosh (x86) Mac OS X
: P3 normal with 4 votes (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-03 10:20 UTC by michael.simons
Modified: 2016-11-23 03:19 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Maven projects demoing failure of including parameter names (3.65 KB, application/x-bzip2)
2015-03-03 10:20 UTC, michael.simons
Details

Note You need to log in before you can comment on or make changes to this bug.
Description michael.simons 2015-03-03 10:20:47 UTC
Created attachment 152352 [details]
Maven projects demoing failure of including parameter names

There seems to be an issue regarding the use of javac's -parameters in Maven projects. When configuring the compiler plugin like so:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <target>1.8</target>
        <source>1.8</source>
        <compilerArgs>
            <arg>-parameters</arg>
        </compilerArgs>	
    </configuration>
</plugin>	  

i expect that the parameter names are retained, for concrete classes as well as abstract classes, interfaces and constructors according to the new Java 8 features regarding parameter names (http://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html).


The concrete example for me using this is Spring Data JPA, where you can declare interfaces and abstract methods that are translated into JPA queries or mapped to existing named queries with named parameters. You can either choose to add an annotion to the interface methods (like i did before) or optain the mapping from parameter names.

Attached is a project that demonstrate the problem. There's a JPA entity with two named queries and a Spring Data JPA Repository that make use of those queries.
The queries contains named parameters. First repo method is annotated with the parameter name, the second not. Spring Data JPA generates implementation on the fly (don’t ask me how). Before Java 8 omitting the @Param wasn’t possible even with debug enabled because there’s no implementation of that method.

Running this in NetBeans 8.0.2
Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Java: 1.8.0_31; Java HotSpot(TM) 64-Bit Server VM 25.31-b07
Runtime: Java(TM) SE Runtime Environment 1.8.0_31-b13
System: Mac OS X version 10.10.2 running on x86_64; UTF-8; de_DE (nb)
User directory: /Users/msimons/Library/Application Support/NetBeans/8.0.1
Cache directory: /Users/msimons/Library/Caches/NetBeans/8.0.1

Basically the generated parameters seem to stay intact when i hit clean & build, then run or debug.
The moment i change the customer repository (just adding an empty line is enough), then debug, the call to findOneByUpperCaseNameWithoutAnnotation fails because Spring Data doesn’t fill the parameter name.

There's an additional readme inside the attached archive.
Comment 1 manica 2015-10-01 18:12:38 UTC
Is there any workaround for this?  I don't see any place to provide compiler arguments in a maven project other than the pom.  Is there any place to add the -parameters argument to CompileOnSave?
Comment 2 milanka 2016-01-08 09:38:42 UTC
Same problem here.

Product Version: NetBeans IDE 8.1 (Build 201510222201)
Java: 1.8.0_66; Java HotSpot(TM) 64-Bit Server VM 25.66-b18
Runtime: Java(TM) SE Runtime Environment 1.8.0_66-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 3 dfranssen 2016-03-25 11:48:57 UTC
Is there already a workaround or fix available?
Comment 4 michael.simons 2016-04-19 11:51:57 UTC
Any chance auf this being addressed anytime soon? Really annoying, especially with Spring Data JPA and query parameter resolution. Thanks.
Comment 5 markiewb 2016-08-26 18:30:34 UTC
I guess the logic is hidden somewhere in org.netbeans.modules.maven.cos.CosChecker
Comment 6 markiewb 2016-10-17 17:47:21 UTC
@milanka@netbeans.org: Do not change the version! The version field contains the NB version the issue has been found first. Please vote instead!

Resetting changes.
Comment 7 Tomas Zezula 2016-11-16 15:05:49 UTC
The java.source.base part: http://hg.netbeans.org/jet-main/rev/ba0af206837d
Comment 8 Tomas Zezula 2016-11-16 15:07:24 UTC
Now maven project needs to implement:
1) CompilerOptionQuieryImplementation providing the options from pom's compiler-plugin
2) Add COQI merger into project's lookup LookupMergerSupport.createCompilerOptionsQueryMerger()
Comment 9 Tomas Stupka 2016-11-16 15:14:03 UTC
> Now maven project needs to implement:
> 1) CompilerOptionQuieryImplementation providing the options from pom's compiler-plugin
> 2) Add COQI merger into project's lookup LookupMergerSupport.createCompilerOptionsQueryMerger()
thanks
Comment 10 Tomas Stupka 2016-11-16 16:02:54 UTC
fixed in jet-main #5b7e60e4eb38
Comment 11 Tomas Stupka 2016-11-16 16:12:29 UTC
please note that we do not plan to add this into the next 8.2 patch release as the necessary infrastructure in java.source (o.n.spi.java.queries.CompilerOptionsQueryImplementation) was introduced just recently into dev builds and is hard to backport
Comment 12 didiez 2016-11-22 16:11:27 UTC
Is there any workaround in the meantime?
Any way to patch my netbeans instalation with the fix?
when its planned the bugfix release for this issue?
Comment 13 Quality Engineering 2016-11-23 03:19:00 UTC
Integrated into 'main-silver', will be available in build *201611230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ba0af206837d
User: Tomas Zezula <tzezula@netbeans.org>
Log: #250858:javac -parameters Option and "Compile on save" in Maven projects