Bug in ojc (compiler)

JDev Team,
OJC successfully compiles the following code but javac does not. Case test compilation should fail since it is not a compile time constant. I have another question though. Why is JDeveloper using OJC? What are the benefits? Please let me know.
final int test;
test = 2;
int x = 0;
switch (x)
case test: System.out.println("case test compiled");
Thanks
Bala.

Hi,
I can reproduce this problem, and I have filed bug 6748835.
One main reason OJC exists is for performance. It's faster than javac, and uses less memory.
Thanks,
Brian

Similar Messages

  • BUG: Oracle Java Compiler bug with anonymous inner classes in constructor

    The following code compiles and runs just fine using 1.4.2_07, 1.5.0_07 and 1.6.0_beta2 when compiling and running from the command-line.
    It does not run when compiling from JDeveloper 10.1.3.36.73 (which uses the ojc.jar).
    When compiled from JDeveloper, the JRE (both the embedded one or the external 1.5.0_07 one) reports the following error:
    java.lang.VerifyError: (class: com/ids/arithmeticexpr/Scanner, method: <init> signature: (Ljava/io/Reader;)V) Expecting to find object/array on
    stack
    Here's the code:
    /** lexical analyzer for arithmetic expressions.
    Fixes the lookahead problem for TT_EOL.
    public class Scanner extends StreamTokenizer
    /** kludge: pushes an anonymous Reader which inserts
    a space after each newline.
    public Scanner( Reader r )
    super( new FilterReader( new BufferedReader( r ) )
    protected boolean addSpace; // kludge to add space after \n
    public int read() throws IOException
    int ch = addSpace ? ' ' : in.read();
    addSpace = ch == '\n';
    return ch;
    public static void main( String[] args )
    Scanner scanner = new Scanner( new StringReader("1+2") ); // !!!
    Removing the (implicit) reference to 'this' in the call to super() by passing an instance of a static inner class 'Kludge' instead of the anonymous subclass of FilterReader fixes the error. The code will then run even when compiled with ojc. There seems to be a bug in ojc concerning references to the partially constructed object (a bug which which is not present in the reference compilers.)
    -- Sebastian

    Thanks Sebastian, I filed a bug for OJC, and I'll look at the Javac bug. Either way, OJC should either give an error or create correct code.
    Keimpe Bronkhorst
    JDev Team

  • How to enable ojc compiler in new oracle jdeveloper 11g IDE

    Hi,
    we can compile java files using ojc compiler in Jdeveloper 10g IDE.
    I need this option in New Jdeveloper 11g IDE.
    Can any one tell me how to enable the ojc compiler? ( I need detailed steps to enable ojc compiler)
    I got class version error while i compile using javac in new Jdeveloper 11g IDE.
    (Class file size also differ from both compiler)
    So that, I want ojc compiler in new Jdeveloper 11g IDE.
    Regards,
    Karthi
    Edited by: user12957451 on May 4, 2010 1:09 AM

    I guess you can't. The ojc compiler is not part of jdev 11g, javac is the tool of choice.
    Timo

  • BUG: ojc compiler doesnt handle @Override on anonymous inner class methods

    Hi,
    jdev 10.1.3.3.0.4157, XP SP2, jdk 5 u13:
    for the following code sample:
    Object o = new Object()
        @Override
        public String toString2()
            return "some string";
    };With ojc set as a compiler (the default), ojc doesnt catch the error about overriding toString with toString2, changing the compiler to javac achieves the required and correct behavior.

    Thanks Frank, I logged a couple more not so serious issues a while back but didnt get any feedback on them. The subject of the posts didn't have a 'BUG' prefix though. Should I edit them so to give them some attention, or were they silently logged :) ?

  • Assert statement (JDK 1.4). Bug in OJC ???!!!

    It appears to be bug in the Oracle Java Compiler (OJC) of JDev 9.0.3 and JDev 9.0.2, if you have an assert statement in a method of a class that has an inner class or in a method of the inner class (any assert statement, anywhere in the code).
    If the assert statement is in a method of the inner class, the OJC reports the following errors:
    Error(x,y): variable $ad not found in class EnclosingClass.InnerClass
    Error(x,y): constructor AssertionError(<anything>) not found in class java.lang.AssertionError
    If the assert statement is in a method of the enclosing class, the OJC reports the following errors:
    Error(p,q): constructor AssertionError(<anything>) not found in class java.lang.AssertionError
    Obviously the option -source 1.4 is passed to the compiler; besides the option
    AddVMOption -DEDITOR_ENABLE_ASSERT=true is set in jdev.conf
    Certainly I can compile the code with the javac compiler of Sun's JDK 1.4.
    Pablo.

    Arno,
    Please disregard Stuart's reply. There has been some confusion happening. We are aware of the issue and it has already been fixed in a subsequent (still not available) release. Please send me an email to [email protected] and I will send you a patch that fixes the issue. The patch is compatible with 9.0.3.1035. I assume that's what you are using.
    Regards,
    Michel

  • Getting bug error while compiling object binding code in javaFX

    I am new to javaFX and exploring it from just last two days.
    today i tried a simple binding object example and got weird exception about bug.
    i created a simple file with name Calculator.fx having just one line public var result=1;and used object binding in another file Customer.fx with following code
    var myStreet=21;
    var address= bind Calculator{
         result:myStreet;
    println({address.result});i got following output error
    init:
    deps-jar:
    Note: An internal error has occurred in the OpenJFX compiler. Please file a bug at the
    Openjfx-compiler issues home (https://openjfx-compiler.dev.java.net/Issues)
    after checking for duplicates.  Include in your report:
    - the following diagnostics
    - file C:\Users\omnidoc\AppData\Local\Temp\javafx_err_59993.txt
    - and if possible, the source file which triggered this problem.
    Thank you.
    C:\cc_storage\Caculator\src\Customer.fx:3: cannot find symbol
    symbol  : variable VOFF$result
    location: class Calculator
    def address= bind Calculator{
    1 error
    ERROR: javafxc execution failed, exit code: 1
    C:\cc_storage\Caculator\nbproject\build-impl.xml:143: exec returned: -1
    BUILD FAILED (total time: 2 seconds)Am i doing something wrong or is it really a bug.
    Also can anyone tell me how to do object binding in javaFX.
    thanks
    chauhan

    chauhan2003 wrote:
    Am i doing something wrong or is it really a bug.When you get such error, that's both: you made a mistake (and at least you get a generally helpful message about it) but the compiler is bugging out and crashing...

  • BUG - Switch statement & compiler

    I am overriding AccordionHeader. In the set Data method I
    have a switch statement. I dont think the location of the statement
    is relevant, but included for completeness. (MenuGroup is my own
    class and not relevant)
    If you have the following code Flex 3 \ FB 3 (both beta 3)
    override public function set data(value:Object):void
    var menuGroup:MenuGroup = value as MenuGroup;
    // examine the groupType to determine if we need \ want to
    change the style setting
    // on this particular header
    switch(menuGroup.groupType)
    super.data = value;
    The compiler will fail with an 'An internal build error has
    occurred' error.
    Put in a default case statement such as
    case default:
    break;
    and all is well.
    regards BOb

    Thanks for reporting. You can track the bug here
    https://bugs.adobe.com/jira/browse/ASC-3113
    Thanks,
    Gaurav Jain
    Flex SDK Team

  • Generics bug in Sun compiler?

    The code show compiles using the oracle compiler, but when executed generate a NoSuchMethodError. Apparently, this doesn't occur when run under Eclipse, presumably compiled byJikes. Is this a known bug? (Compiled using 1.6.0_21)
    public class Bug  {
        public static void main(String[] args) {
            X x = new X();
            x.da();
        public static interface A {
            void foo();
        public static interface B {
            void bar();
        public static class FooBar implements A, B {
            @Override public void foo() {
            @Override public void bar() {
        public static class Z<T extends A & B, TT extends T> {
            final TT t;
            public Z(final TT t) {
                this.t = t;
            void da() {
                    t.foo();
                    t.bar();
        public static class X extends Z<FooBar, FooBar> {
            public X() {
                super(new FooBar());
    }Exception in thread "main" java.lang.NoSuchMethodError: com.iontrading.anvil.tradelibrary.bus.Bug$A.bar()V
         at com.iontrading.anvil.tradelibrary.bus.Bug$Z.da(Bug.java:40)
         at com.iontrading.anvil.tradelibrary.bus.Bug.main(Bug.java:8)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

    rxcolvin wrote:
    Apparently, this doesn't occur when run under Eclipse, presumably compiled byJikes.Minor correction: Eclipse doesn't use Jikes (and as far as I know never did). They do have their own compiler however (called simply the Eclipse Java Compiler). ECJ is written in Java, as opposed to Jikes, which is written in C++.
    Edit: confirmed to be broken with javac from the Sun JDK (6u22) and the OpenJDK 1.6.0_20. Works when compiled with the Eclipse compiler (both with conformance 1.5 and 1.6) from an up-to-date Eclipse 3.6.1.
    It wouldn't be the first time that ECJ gets something right that javac doesn't compile correctly.

  • Optimizer bug in C compiler for Linux

    Save the following as bug.c:
    Bug report against Sun C for Linux:
    $ suncc -V
    cc: Sun C 5.9 Linux_i386 Build27_2 2006/08/02
    usage: cc [ options] files.  Use 'cc -flags' for details
    $ cat /etc/SuSE-release
    SuSE Linux 9.3 (x86-64)
    VERSION = 9.3
    $ uname -r
    2.6.11.4-21.8-smp
    Compiled w/ -xO2 or lower, this program runs to completion:
    $ suncc -xO2 bug.c -o bug -lpthread && ./bug
    Hello from thread 0
    Hello from thread 1
    Hello from thread 2
    Hello from thread 3
    DONE.
    However, when compiled w/ -xO3 (or higher) this program hangs:
    $ suncc -xO3 bug.c -o bug -lpthread && ./bug
    Hello from thread 0
    Hello from thread 1
    Hello from thread 2
    Hello from thread 3
    ...hung here...
    ^C
    Changing "#if 0" to "#if 1" changes a "while (cond) {body;}" to a
    "do {body;} while(cond)", and is sufficient to work around the
    problem in this case.
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    #include <pthread.h>
    static unsigned int numthreads = 4;
        static void test_pthread_barrier(void) {
          static pthread_cond_t barrier_cond[2] =
            { PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER };
          static pthread_mutex_t barrier_mutex[2] =
            { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER };
          static volatile unsigned int barrier_count = 0;
          static volatile int phase = 0;
          const int myphase = phase;
          pthread_mutex_lock(&barrier_mutex[phase]);
          barrier_count++;
          if (barrier_count < numthreads) {
    #if 0
            do {
              pthread_cond_wait(&barrier_cond[myphase], &barrier_mutex[myphase]);
            } while (myphase == phase);
    #else
            while (myphase == phase) {
              pthread_cond_wait(&barrier_cond[myphase], &barrier_mutex[myphase]);
    #endif
          } else {
            barrier_count = 0;
            phase = !phase;
            pthread_cond_broadcast(&barrier_cond[!phase]);
          pthread_mutex_unlock(&barrier_mutex[!phase]);
    static void * thread_main(void * arg) {
      printf("Hello from thread %d\n", (int)(uintptr_t)arg);
      test_pthread_barrier();
      return NULL;
    int main(void) {
        int i;
        pthread_t *threadid = (pthread_t *)malloc(sizeof(pthread_t)*numthreads);
        for(i=0;i<numthreads;i++) {
          void *threadarg;
          pthread_attr_t attr;
          pthread_attr_init(&attr);
          pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); /* ignore failures */
          pthread_create(&threadid, &attr, &thread_main, (void *)(uintptr_t)i);
    pthread_attr_destroy(&attr);
    for(i=0;i<numthreads;i++) {
    void *retval = NULL;
    pthread_join(threadid[i], &retval);
    free(threadid);
    printf("DONE.\n");
    return 0;

    You can refer to this bug as 6499729.
    The bug status will soon be visible on bugs.sun.com

  • BUG? :: Short Hand IF BUG cause flash compile engine to go haywire x_x

    var MyCurrentValue:String = "TEST";
    var MyOperatorBug:Boolean = !(MyCurrentValue != null ? MyCurrentValue.length > 0 : false); 
    trace(MyOperatorBug)
    Copy paste the above script into your ActionScript 3.0 Flash CS 4 IDE
    What this script do is , it checks variable MyCurrentValue if it is null or not
    if it is not null then it will check if its length is more then 0
    try running the above code will result the flash does not produce any compile / warning error, it will not result in run time error either
    it will not trace the MyOperatorBug variable either..
    Is it a bug ? or i am just missing something?!
    Cheers and God Bless,
    Chowi

    thanks for the speedy reply
    but can you tell me whats wrong with my first code? and why if it is an error, the flash did not print out any warning / run time error
    here is my other experiment that makes me even more curious, if i put the BOLD Text into a variable first, it works!
    NOT WORKING (WHY NO ERROR? No Warning , No Runtime ERROR, NOTHING, it simply does nothing)
    var MyCurrentValue:String = "TEST";
    var MyOperatorBug:Boolean = !(MyCurrentValue != null ? MyCurrentValue.length > 0 : false); 
    trace(MyOperatorBug)
    WORKING
    var MyCurrentValue:String = "TEST";
    var MyBoolean:Boolean = MyCurrentValue != null ? MyCurrentValue.length > 0 : false;
    var MyOperatorBug:Boolean = !(MyBoolean); 
    trace(MyOperatorBug)
    i am actually not looking for a solution, since i know how to get around with this, what i am asking is why is the first code not working, and not only that, it cause the flash to stop compiling without reporting any error x_x
    Cheers and God Bless,
    Chowi

  • LV2012 Out of Memory Bug when Clearing Compiled Object Cache

    Here is some LV2012 weird behaviour when clearing the compiled cache and having a project with source code separated from the binaries.
    Steps to reproduce:
    1. Open a VI in a fairly large LV project
    2. With the VI open, clear the compiled cache:
    3. Close the VI.
    4. Open the VI
    5. Watch the broken arrow and the LV Out of Memory bogus.
    Br,
    /Roger
    Solved!
    Go to Solution.

    Norbert_B wrote:
    Roger,
    i tracked down the issue to "ExecutionBenchmark1.lvclass:Load Core.vi" and "ExecutionBenchmark2.lvclass:Load Core.vi". If removing both VIs from the main, it is compilable.
    Since those VIs have their blockdiagram removed, they have to include their compilation in order to be executable. I expect this to be the source of the issue.
    Can you please check if using the default VI "Load Core" for both classes work as long as LV is able to recompile those while creating the object file for the main?
    thanks,
    Norbert
    Yep, still reproducible on my 32 bit Windows 7 home machine. Attached is the fixed code.
    Also, my suspicion was right. If you try to save a project in a out of memory condition, the saved project will always display an out of memory error due to a missing block diagram.
    Br,
    /Roger
    Attachments:
    Execution_Fixed.zip ‏415 KB
    Missing_BD.zip ‏419 KB

  • Bug with gcc compiler

    I saw the below article and was wondering if this was a problem with arch linux as well or not.  I do not see any thing listed in the advisory section so was not sure about this.
    http://blogs.computerworld.com/14583/fixing_linux

    Since it says that it's fixed in 2.6.30.5 and the latest version on arch is 2.6.30.5, then it's probably not an issue. (if you are actually using the latest kernel on arch)
    [oh@Alice][~]%pacman -Si kernel26
    Repository : core
    Name : kernel26
    Version : 2.6.30.5-1
    URL : http://www.kernel.org
    Licences : GPL2
    Groups : base
    Provides : None
    Depends On : coreutils kernel26-firmware>=2.6.30 module-init-tools mkinitcpio>=0.5.20
    Optional Deps : crda: to set the correct wireless channels of your country
    Conflicts With : None
    Replaces : kernel24 kernel24-scsi kernel26-scsi alsa-driver ieee80211 hostap-driver26 pwc nforce squashfs unionfs ivtv
    zd1211 kvm-modules iwlwifi rt2x00-cvs gspcav1 atl2 wlan-ng26 aufs rt2500
    Download Size : 34564.71 K
    Installed Size : 133676.00 K
    Packager : Thomas Baechler <[email protected]>
    Architecture : x86_64
    Build Date : Mon 17 Aug 2009 16:19:04 CEST
    MD5 Sum : 4add217467ce2add37cc12874ab03ced
    Description : The Linux Kernel and modules
    Last edited by Mr.Elendig (2009-08-21 16:35:10)

  • Ojc will compile the following class. A bug?

    I thought that in Java classes cannot be declared protected. ojc will however compile the following class:
    protected class aclass
    The Sun java compiler prints the following error:
    aclass.java:1: modifier protected not allowed here
    protected class aclass
    Is this a known bug in the Oracle Java compiler?

    Yes, it seems we have a little bug in OJC, the protected access modifier should only be allowed for member classes. I filed a bug report and I'll fix it.
    Thanks!
    Keimpe Bronkhorst
    JDev Team

  • Bug in Oracle Java Compiler???

    Hello!
    I think I found a bug in OJC. Take a look in these files:
    ------ File MyInterface1.java -------
    public interface MyInterface1
    public void aMethod1();
    public void aMethod2();
    ------ File MyInterface2.java -------
    public interface MyInterface2 extends MyInterface1
    public void aMethod1(String s1);
    public void aMethod2(String s2);
    ------ File MyAbstractClass.java -------
    abstract public class MyAbstractClass implements MyInterface2
    public void aMethod1()
    ------ File MyImplClass.java -------
    public class MyImplClass extends MyAbstractClass
    public void aMethod2()
    public void aMethod1(String s)
    When compiling these files, the following error should be found:
    "javac MyImplClass.java
    MyImplClass.java:1: MyImplClass should be declared abstract; it does not define
    aMethod2(java.lang.String) in MyAbstractClass
    public class MyImplClass extends MyAbstractClass
    ^
    1 error"
    This is the error found by javac (J2SE 1.3), as expected.
    But when I compile using OJC 9.0.2.579 (JDeveloper 9.0.2.829) no error is found, and the compiler generates MyImplClass.class. This should not happen!!!
    Even if I implement aMethod2(String s) in MyImplClass, how can I trust that OJC is generating the bytecode, so that the method invocation is occuring correctly during runtime?
    I have a component library based on class hierarchy like the one in the example, and I would not like to modify it because of this possible bug in OJC.
    Thanks
    Gleber/Daniel/Augusto

    Gleber,
    As per current plans the 903 release is expected to be on OTN in the next 5-7 weeks. Feel free to ping me at [email protected] if this bug is preventing you from moving forward. I'll try to resolve your issue with a workaround.
    Regards,
    Arun

  • BUG: OJC creates different classes than JAVAC making them incompatible

    Using the new JDeveloper 10g production release, I saw this behaviour when I used a class compiled in JDev (with OJC) passed over RMI to a server running classes compiled with in Ant (with JAVAC).
    I took the problematic class and stripped away parts of it until I have isolated the cause - seems related to class variable members initialization.
    I will provide several exapmles, where I used several modifications, giving the output of JAVAP for the same class, once compiled by JAVAC and once by OJC, highlighting the diff.
    Example #1:
    public class Test { static final int CONSTANT = 0; }JAVAC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        static final int CONSTANT;
        public Test();
    }OJC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        static final int CONSTANT;
        static {};
        public Test();
    Example #2:
    public class Test { final int CONSTANT = 0; }JAVAC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        final int CONSTANT;
        public Test();
    }OJC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        final int CONSTANT;
        void $init$();
        public Test();
    Example #3:
    public class Test { static int CONSTANT = 0; }JAVAC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        static int CONSTANT;
        public Test();
        static {};
    }OJC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        static int CONSTANT;
        static {};
        public Test();
    Example #4:
    public class Test { int CONSTANT = 0; }JAVAC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        int CONSTANT;
        public Test();
    }OJC:
    Compiled from "Test.java"
    public class Test extends java.lang.Object{
        int CONSTANT;
        void $init$();
        public Test();
    }I also have two examples where both compilers produce the same output for JAVAP:
    public class Test { static int CONSTANT; }
    public class Test { int CONSTANT; }I hope this is enough information to solve this.
    Classes compiled with OJC should not be incompatible with classes compiled with JAVAC with the same settings!
    Regards,
    Yaniv Kunda

    I'm sorry but I'm too busy with an urgent project to set up a RMI client/server testbed for this to test this problem, but all the example I gave are ones I've performed myself, and which all work - a simple class containing a constant (in several variations of its modifiers) compiled once with JAVAC and once with OJC produced different classes.
    I simply used javap to find out the difference between the classes, and highlighted the differences in bold - that would be a good place to start looking for the bug.
    Besides I'm not sure how to create a test that loads two versions of the same class not using RMI (perhaps via a special ClassLoader?)
    Regards,
    Yaniv Kunda

Maybe you are looking for