You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2019/07/06 15:23:00 UTC

[jira] [Commented] (BCEL-285) "ClassFormatException: Invalid signature" thrown on generics

    [ https://issues.apache.org/jira/browse/BCEL-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16879705#comment-16879705 ] 

Gary Gregory commented on BCEL-285:
-----------------------------------

Where is Main.class?

> "ClassFormatException: Invalid signature" thrown on generics
> ------------------------------------------------------------
>
>                 Key: BCEL-285
>                 URL: https://issues.apache.org/jira/browse/BCEL-285
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 6.0
>         Environment: java 8, macOS 10.12.2
>            Reporter: Tom Brus
>            Priority: Major
>
> The following stripped down example throws an Exception in {{BCEL}}:
> {code:title=Bar.java|borderStyle=solid}
> import java.io.IOException;
> import java.util.stream.Stream;
> import org.apache.bcel.classfile.ClassParser;
> public class Main {
>   public static void main(String[] args) throws IOException {
>     ClassParser parser = new ClassParser(Main.class.getResourceAsStream("Main.class"), "Main.class");
>     parser.parse().getMethods()[2].getCode().toString(); /* <- EXCEPTION thrown */
> 		
>     ((Stream<? extends Object>)null).peek(x -> {}); /* <- problem spot */
>   }
> }
> {code}
> The exception is:
> {code}
> Exception in thread "main" org.apache.bcel.classfile.ClassFormatException: Invalid signature: `!+Ljava/lang/Object;'
> 	at org.apache.bcel.classfile.Utility.signatureToString(Utility.java:930)
> 	at org.apache.bcel.classfile.LocalVariable.toStringShared(LocalVariable.java:187)
> 	at org.apache.bcel.classfile.LocalVariableTypeTable.toString(LocalVariableTypeTable.java:121)
> 	at java.lang.String.valueOf(String.java:2994)
> 	at java.lang.StringBuilder.append(StringBuilder.java:131)
> 	at org.apache.bcel.classfile.Code.toString(Code.java:316)
> 	at org.apache.bcel.classfile.Code.toString(Code.java:328)
> 	at Main.main(Main.java:9)
> {code}
> This problem only occurs in eclipse (I am using NEON.2) and does not occur in Intellij (I am using 2016.3.2). This probably indicates that {{ecj}} and {{javac}} differ in their class code generator.
> Since our project uses {{sonar:findbugs}} which uses {{BCEL}} this is a major problem for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)