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 242428 - Failure to find Jackpot matches
Summary: Failure to find Jackpot matches
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Linux
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-27 18:30 UTC by Jesse Glick
Modified: 2016-07-07 07:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2014-02-27 18:30:57 UTC
Product Version = NetBeans IDE Dev (Build 20140219-56d93f8aa028)
Operating System = Linux version 3.11.0-17-generic running on amd64
Java; VM; Vendor = 1.7.0_51
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.51-b03

If in [github,com/jenkinsci/jenkins@ef47420/]core/src/main/resources/META-INF/upgrade/ I create an IOUtils.hint containing

hudson.util.IOUtils.toString($args$) => org.apache.commons.io.IOUtils.toString($args$);

and then run the inspection on core/src/main/java/hudson/model/UpdateSite.java, I get two matches as expected (lines 167, 193) and the refactoring preview diff window looks fine. But if I add another method to the hint

hudson.util.IOUtils.toString($args$) => org.apache.commons.io.IOUtils.toString($args$);
hudson.util.IOUtils.toInputStream($args$) => org.apache.commons.io.IOUtils.toInputStream($args$);

then the IDE reports a bogus error for each occurrence:

More than one fix for: IOUtils at UpdateSite.java:166, only the first one will be used.

and disables the Refactor button; the Inspect button if clicked claims there are no matches.

When I create a file with *all* the desired hints:

<!description="PRs #1135, #1138: use IOUtils from Apache commons">
hudson.util.IOUtils.DIR_SEPARATOR_UNIX => org.apache.commons.io.IOUtils.DIR_SEPARATOR_UNIX;
hudson.util.IOUtils.DIR_SEPARATOR_WINDOWS => org.apache.commons.io.IOUtils.DIR_SEPARATOR_WINDOWS;
hudson.util.IOUtils.DIR_SEPARATOR => org.apache.commons.io.IOUtils.DIR_SEPARATOR;
hudson.util.IOUtils.LINE_SEPARATOR_UNIX => org.apache.commons.io.IOUtils.LINE_SEPARATOR_UNIX;
hudson.util.IOUtils.LINE_SEPARATOR_WINDOWS => org.apache.commons.io.IOUtils.LINE_SEPARATOR_WINDOWS;
hudson.util.IOUtils.LINE_SEPARATOR => org.apache.commons.io.IOUtils.LINE_SEPARATOR;
hudson.util.IOUtils.closeQuietly($args$) => org.apache.commons.io.IOUtils.closeQuietly($args$);
hudson.util.IOUtils.toByteArray($args$) => org.apache.commons.io.IOUtils.toByteArray($args$);
hudson.util.IOUtils.toCharArray($args$) => org.apache.commons.io.IOUtils.toCharArray($args$);
hudson.util.IOUtils.toString($args$) => org.apache.commons.io.IOUtils.toString($args$);
hudson.util.IOUtils.readLines($args$) => org.apache.commons.io.IOUtils.readLines($args$);
hudson.util.IOUtils.lineIterator($args$) => org.apache.commons.io.IOUtils.lineIterator($args$);
hudson.util.IOUtils.toInputStream($args$) => org.apache.commons.io.IOUtils.toInputStream($args$);
hudson.util.IOUtils.write($args$) => org.apache.commons.io.IOUtils.write($args$);
hudson.util.IOUtils.writeLines($args$) => org.apache.commons.io.IOUtils.writeLines($args$);
// Cannot use $args$ wildcard for copy since there are two non-deprecated overloads:
hudson.util.IOUtils.copy($input, $output) :: $input instanceof java.io.InputStream && $output instanceof java.io.OutputStream => org.apache.commons.io.IOUtils.copy($input, $output);
hudson.util.IOUtils.copy($input, $output) :: $input instanceof java.io.InputStream && $output instanceof java.io.Writer => org.apache.commons.io.IOUtils.copy($input, $output);
hudson.util.IOUtils.copy($input, $output, $encoding) :: $input instanceof java.io.InputStream && $output instanceof java.io.Writer && $encoding instanceof java.lang.String => org.apache.commons.io.IOUtils.copy($input, $output, $encoding);
hudson.util.IOUtils.copy($input, $output) :: $input instanceof java.io.Reader && $output instanceof java.io.Writer => org.apache.commons.io.IOUtils.copy($input, $output);
hudson.util.IOUtils.copy($input, $output) :: $input instanceof java.io.Reader && $output instanceof java.io.OutputStream => org.apache.commons.io.IOUtils.copy($input, $output);
hudson.util.IOUtils.copy($input, $output, $encoding) :: $input instanceof java.io.Reader && $output instanceof java.io.OutputStream && $encoding instanceof java.lang.String => org.apache.commons.io.IOUtils.copy($input, $output, $encoding);
hudson.util.IOUtils.copyLarge($args$) => org.apache.commons.io.IOUtils.copyLarge($args$);
hudson.util.IOUtils.contentEquals($args$) => org.apache.commons.io.IOUtils.contentEquals($args$);

the IDE silently claims no matches at all.
Comment 1 Jan Lahoda 2014-02-27 18:52:37 UTC
Admittedly, the error checking leaves a lot to be desired in this case, but the problem, I think, are the missing ';;' between individual rules (so in the first case, the engine sees one rule with two fixes, instead of two rules).
Comment 2 Jesse Glick 2014-02-27 22:22:10 UTC
Ah! That works. Yes the error checking is the problem here. (Not sure what it _thought_ I was trying to say.)
Comment 3 Jesse Glick 2014-02-27 22:24:32 UTC
By the way, at least in this case, applying the fix fails to remove the hudson.util.IOUtils import (now unused), or import org.apache.commons.io.IOUtils (now a FQN), even in case where no other hudson.util.IOUtils members were being used in the compilation unit. Not sure if you would consider that a bug.
Comment 4 Martin Balin 2016-07-07 07:16:50 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss