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 213019 - "instanceof java.lang.Class<? extends some.Type>" does not seem to work
Summary: "instanceof java.lang.Class<? extends some.Type>" does not seem to work
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-25 13:45 UTC by Jesse Glick
Modified: 2016-07-07 07:18 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 2012-05-25 13:45:11 UTC
Noticing an unnecessarily complex idiom in PlatformInstallTest.java, I tried to write a rule to simplify it:

diff --git a/nbjunit/src/META-INF/upgrade/NbModuleSuite.hint b/nbjunit/src/META-INF/upgrade/NbModuleSuite.hint
--- a/nbjunit/src/META-INF/upgrade/NbModuleSuite.hint
+++ b/nbjunit/src/META-INF/upgrade/NbModuleSuite.hint
@@ -2,3 +2,8 @@
 =>
 $c.suite()
 ;;
+
+org.netbeans.junit.NbModuleSuite.emptyConfiguration().addTest($c) :: $c instanceof java.lang.Class<? extends junit.framework.TestCase>
+=>
+org.netbeans.junit.NbModuleSuite.createConfiguration($c)
+;;
diff --git a/nbjunit/test/unit/src/META-INF/upgrade/NbModuleSuite.test b/nbjunit/test/unit/src/META-INF/upgrade/NbModuleSuite.test
--- a/nbjunit/test/unit/src/META-INF/upgrade/NbModuleSuite.test
+++ b/nbjunit/test/unit/src/META-INF/upgrade/NbModuleSuite.test
@@ -12,3 +12,20 @@
         return org.netbeans.junit.NbModuleSuite.createConfiguration(SomeTest.class).gui(false).suite();
     }
 }
+%%TestCase createConfiguration
+package test;
+public class SomeTest extends org.netbeans.junit.NbTestCase {
+    public static junit.framework.Test suite() {
+        return org.netbeans.junit.NbModuleSuite.emptyConfiguration().addTest(SomeTest.class).gui(false).suite();
+    }
+}
+%%=>
+package test;
+
+import org.netbeans.junit.NbModuleSuite;
+
+public class SomeTest extends org.netbeans.junit.NbTestCase {
+    public static junit.framework.Test suite() {
+        return NbModuleSuite.createConfiguration(SomeTest.class).gui(false).suite();
+    }
+}

Unfortunately the *.test says "incorrect output" and when it offers to put "actual output" into golden section, it just writes

...
%%=>
NbModuleSuite:addTest

Also in the actual source file, the hint offers no fix, and the warning says just "NbModuleSuite". I also see in my log file:

INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=$.$ ]

If I comment out the "<? extends junit.framework.TestCase>" qualifier, then the test passes and the hint works. Unfortunately that is not safe in this case, since addTest(Class<? extends Test>) is a different overload that behaves differently and cannot be rewritten using this rule.
Comment 1 Jan Lahoda 2012-05-28 05:39:51 UTC
Workaround: place a space between "<" and "?". I'll see if this can be fixed, or if this workaround must be documented as the only way to express wildcards.
Comment 2 Martin Balin 2016-07-07 07:18:38 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