public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/38827]  New: gcj emitting incorrect code
@ 2009-01-13 16:03 tschwinge at gcc dot gnu dot org
  2009-01-13 19:22 ` [Bug java/38827] " pinskia at gmail dot com
  2009-01-13 20:37 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: tschwinge at gcc dot gnu dot org @ 2009-01-13 16:03 UTC (permalink / raw)
  To: java-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2022 bytes --]

I originally found this problem when trying to compile a Java package written
by the Universität Stuttgart's institute IKR.  I was using Debian's gcj
package, version 4.3.2-2, but can likewise reproduce this using SVN trunk, as
well as Debian's 4.2.4-4 package.

I completely reduced the test case to the following:

    public class Bug_Class
    {
    }

    public interface Bug_Interface
    {
    }

    public class Bug
    {
        public <X extends Bug_Class & Bug_Interface> Bug(X x)
        {
            set(x);
        }

        public void set(Bug_Interface x)
        {
        }
    }

Directly compiling this will fail as follows:

    $ ~/GCC/trunk.build.64.install/bin/gcj -c Bug.java
    Bug.java: In class 'Bug':
    Bug.java: In constructor '(Bug_Class)':
    In file included from <built-in>:3:
    Bug.java:3: error: verification failed at PC=9: incompatible type on stack

gcj is able to emit a class file, but that one is considered non-verifying by
the BCEL verifier:

    [...]
    Pass 3b, method number 0 ['public void <init>(Bug_Class arg1)
[Signature(<E:LBug_Class;:LBug_Interface;>(TE;)V)]']:
    VERIFIED_REJECTED
    Constraint violated in method 'public void <init>(Bug_Class arg1)
[Signature(<E:LBug_Class;:LBug_Interface;>(TE;)V)]':
    Instruction INVOKEVIRTUAL constraint violated: Expecting a 'Bug_Interface'
but found a 'Bug_Class' on the stack (which is not assignment compatible).
    InstructionHandle:    6: invokevirtual[182](3) 13
    [...]

What Sun's javac does differently (as per class-file disassembly inspection) is
emitting a checkcast against class Bug_Interface before calling invokevirtual.


-- 
           Summary: gcj emitting incorrect code
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tschwinge at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38827


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug java/38827] gcj emitting incorrect code
  2009-01-13 16:03 [Bug java/38827] New: gcj emitting incorrect code tschwinge at gcc dot gnu dot org
@ 2009-01-13 19:22 ` pinskia at gmail dot com
  2009-01-13 20:37 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gmail dot com @ 2009-01-13 19:22 UTC (permalink / raw)
  To: java-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2526 bytes --]



------- Comment #1 from pinskia at gmail dot com  2009-01-13 19:22 -------
Subject: Re:   New: gcj emitting incorrect code



On Jan 13, 2009, at 8:03 AM, "tschwinge at gcc dot gnu dot org"
<gcc-bugzilla@gcc.gnu.org 
 > wrote:

> I originally found this problem when trying to compile a Java  
> package written
> by the Universität Stuttgart's institute IKR.  I was using Debian's  
> gcj
> package, version 4.3.2-2, but can likewise reproduce this using SVN  
> trunk, as
> well as Debian's 4.2.4-4 package.
>
> I completely reduced the test case to the following:
>
>    public class Bug_Class
>    {
>    }
>
>    public interface Bug_Interface
>    {
>    }
>
>    public class Bug
>    {
>        public <X extends Bug_Class & Bug_Interface> Bug(X x)
>        {
>            set(x);
>        }
>
>        public void set(Bug_Interface x)
>        {
>        }
>    }
>
> Directly compiling this will fail as follows:
>
>    $ ~/GCC/trunk.build.64.install/bin/gcj -c Bug.java
>    Bug.java: In class 'Bug':
>    Bug.java: In constructor '(Bug_Class)':
>    In file included from <built-in>:3:
>    Bug.java:3: error: verification failed at PC=9: incompatible type  
> on stack
>
> gcj is able to emit a class file, but that one is considered non- 
> verifying by
> the BCEL verifier:

This sounds like a bug in the eclispe source to bytecode compiler  
which gcj uses now.




>
>
>    [...]
>    Pass 3b, method number 0 ['public void <init>(Bug_Class arg1)
> [Signature(<E:LBug_Class;:LBug_Interface;>(TE;)V)]']:
>    VERIFIED_REJECTED
>    Constraint violated in method 'public void <init>(Bug_Class arg1)
> [Signature(<E:LBug_Class;:LBug_Interface;>(TE;)V)]':
>    Instruction INVOKEVIRTUAL constraint violated: Expecting a  
> 'Bug_Interface'
> but found a 'Bug_Class' on the stack (which is not assignment  
> compatible).
>    InstructionHandle:    6: invokevirtual[182](3) 13
>    [...]
>
> What Sun's javac does differently (as per class-file disassembly  
> inspection) is
> emitting a checkcast against class Bug_Interface before calling  
> invokevirtual.
>
>
> -- 
>           Summary: gcj emitting incorrect code
>           Product: gcc
>           Version: 4.3.2
>            Status: UNCONFIRMED
>          Severity: normal
>          Priority: P3
>         Component: java
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: tschwinge at gcc dot gnu dot org
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38827
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38827


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug java/38827] gcj emitting incorrect code
  2009-01-13 16:03 [Bug java/38827] New: gcj emitting incorrect code tschwinge at gcc dot gnu dot org
  2009-01-13 19:22 ` [Bug java/38827] " pinskia at gmail dot com
@ 2009-01-13 20:37 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-13 20:37 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-01-13 20:37 -------
Can you see if the normal eclipse compiler that comes with the eclipse IDE has
the same issue, and maybe report it to them if so?

GCJ no longer includes a source compiler, we use the eclipse compiler (this was
done in 4.3 and above and also in Debian's 4.2).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38827


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-13 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-13 16:03 [Bug java/38827] New: gcj emitting incorrect code tschwinge at gcc dot gnu dot org
2009-01-13 19:22 ` [Bug java/38827] " pinskia at gmail dot com
2009-01-13 20:37 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).