adam-waldenberg opened a new issue, #5667:
URL: https://github.com/apache/netbeans/issues/5667

   ### Apache NetBeans version
   
   Apache NetBeans 17
   
   ### What happened
   
   I have the following method defined inside a test class:
   
   ```java
   @Property(tries = 10)
   public void randomPublicKeysShouldBeInvalid(@ForAll 
@Size(Signature.PRIVATE_KEY_HEX_SIZE)
        byte[] privateKey) {
   
        assertThat(NetworkKey.isTrusted(Hex.encodeHexString(privateKey)), 
is(false));
   }
   ```
   
   This crashes the parser during the `background scanning` phase and currupts 
the cache. As a result, this is causing red markings in several test classes. 
Signature.PRIVATE_KEY_HEX_SIZE is an integer constant (`public final static 
int`) defined inside an external class:
   
   
![image](https://user-images.githubusercontent.com/1555683/225552565-d1f74f00-3544-48cb-a32a-74a7ceec0ca8.png)
   
   With the fault, the following exception is also thrown:
   ```
   java.lang.AssertionError: <error>
        at 
com.sun.tools.javac.jvm.ClassWriter$AttributeWriter.visitError(ClassWriter.java:626)
        at com.sun.tools.javac.code.Attribute$Error.accept(Attribute.java:386)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeCompoundAttribute(ClassWriter.java:644)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeTypeAnnotation(ClassWriter.java:650)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeTypeAnnotations(ClassWriter.java:553)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:375)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1012)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1479)
        at 
com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1584)
        at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1505)
        at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:738)
        at 
com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1635)
        at 
com.sun.tools.javac.api.JavacTaskImpl$2.process(JavacTaskImpl.java:475)
        at 
com.sun.tools.javac.api.JavacTaskImpl$Filter.run(JavacTaskImpl.java:519)
        at 
com.sun.tools.javac.api.JavacTaskImpl.generate(JavacTaskImpl.java:478)
        at 
org.netbeans.modules.java.source.indexing.VanillaCompileWorker$2.run(VanillaCompileWorker.java:369)
        at 
org.netbeans.modules.java.source.parsing.FileManagerTransaction.runConcurrent(FileManagerTransaction.java:180)
   [catch] at 
org.netbeans.modules.java.source.indexing.VanillaCompileWorker.compile(VanillaCompileWorker.java:356)
        at 
org.netbeans.modules.java.source.indexing.JavaCustomIndexer.index(JavaCustomIndexer.java:360)
        at 
org.netbeans.modules.parsing.spi.indexing.Indexable$MyAccessor$2.run(Indexable.java:138)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runIndexer(RepositoryUpdater.java:274)
        at 
org.netbeans.modules.parsing.spi.indexing.Indexable$MyAccessor.index(Indexable.java:136)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doIndex(RepositoryUpdater.java:2749)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.lambda$index$0(RepositoryUpdater.java:2626)
        at 
org.netbeans.modules.parsing.impl.indexing.errors.TaskCache.refreshTransaction(TaskCache.java:540)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.index(RepositoryUpdater.java:2625)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$AbstractRootsWork.lambda$scanSource$3(RepositoryUpdater.java:5735)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.lambda$runInContext$4(RepositoryUpdater.java:2119)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runInContext(RepositoryUpdater.java:2117)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.runInContext(RepositoryUpdater.java:2098)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.access$1400(RepositoryUpdater.java:135)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$AbstractRootsWork.scanSource(RepositoryUpdater.java:5770)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$AbstractRootsWork.scanSources(RepositoryUpdater.java:5443)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$RootsWork.getDone(RepositoryUpdater.java:5075)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doTheWork(RepositoryUpdater.java:3452)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task._run(RepositoryUpdater.java:6197)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.access$3400(RepositoryUpdater.java:5855)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.lambda$call$0(RepositoryUpdater.java:6116)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
        at 
org.netbeans.modules.parsing.impl.RunWhenScanFinishedSupport.performScan(RunWhenScanFinishedSupport.java:83)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.call(RepositoryUpdater.java:6116)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task$2.call(RepositoryUpdater.java:6112)
        at 
org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
        at 
org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
        at 
org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
        at 
org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
        at 
org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.run(RepositoryUpdater.java:6112)
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at 
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
        at 
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
        at 
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
   ```
   
   If I modify the method definition slightly and change the `@Size` annotation 
to the following, it starts working. However, it only starts working if I have 
deleted the cache directory beforehand. 
   
   ```
   @Property(tries = 10)
   public void randomPublicKeysShouldBeInvalid(@ForAll @Size(65) byte[] 
privateKey) {
        assertThat(NetworkKey.isTrusted(Hex.encodeHexString(privateKey)), 
is(false));
   }
   ```
   
   ### How to reproduce
   
   Something similar to the following should trigger the above error:
   
   ```java
   public class MyTest extends SomeBaseTestClass {
        @Property
        public void 
shouldSomethingSomething(@Size(Signature.PRIVATE_KEY_HEX_SIZE) byte[] 
privateKey) {
                /* Some code ... */
        }
   }
   
   public class Signature {
        public static final int PRIVATE_KEY_HEX_SIZE = 65;
   }
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Linux
   
   ### JDK
   
   JDK 11, JDK 17
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer, Other
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to