Re: Compiler mystery: Compiles classes that don't compile




<peeping_t@xxxxxxxxxxx> wrote in message news:1141164572.509560.238590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Can someone please try and explain how this could even happen.

I'm about to start fixing some bugs in a program for a client. They
haven't really been that organised and just gave me some source code
from somewhere, which may or may not be the version of the source code
that was used to compile the version of the app that I am supposed to
fix bugs in.
Now to the problem. The code doesn't even compile. There's a file
Container.java, which is missing heaps of methods (private ones I guess
as they are only called from inside Container). I decompiled the actual
application and when I look at Container every single method that calls
one of the missing methods are decompiled to something similar like
this

public void open()
{
throw new Error("Unresolved compilation problems:\n\tThe method
initMenu() is undefined for the type Container\n\tThe method handle()
is undefined for the type <anonymous subclass of
SelectionAdapter>\n\tThe method loadSettings() is undefined for the
type Container\n\tThe method init() is undefined for the type
Container\n\tThe constructor Blue(Container) is undefined\n");
}

I don't understand how the compiler managed to compile this class and
replace the method body for the methods calling missing methods with
throw new Error("Unresolved...")

The thing is the application still works as Container is only
referenced as Container.class.getResourceAsStream(...)

The previous programmer was obviously doing some heavy refactoring to
get rid of the Container class, but managed to miss a couple of places
where the class was just referenced as Container.class

I still don't get how the compiler managed to produce a Container.class
file though

Eclipse lets you run classes with compile errors. I'm assuming it does this by replacing the bodies of those methods with "throw new exception" code, as you've described here.

Perhaps your code was compiled by Eclipse or a similar compiler.

- Oliver

.



Relevant Pages

  • Compiler mystery: Compiles classes that dont compile
    ... I'm about to start fixing some bugs in a program for a client. ... The code doesn't even compile. ... as they are only called from inside Container). ... one of the missing methods are decompiled to something similar like ...
    (comp.lang.java.help)
  • Re: STL::list trouble in VC6
    ... | not compile, as sizeofcould be used in the definition ... or I just found another bug in my compiler. ... | It's undefined behaviour to instantiate a standard container ... Chris Val ...
    (alt.comp.lang.learn.c-cpp)
  • Re: STL::list trouble in VC6
    ... Chris wrote: ... > | dwizard wrote: ... not compile, as sizeofcould be used in the definition ... It's undefined behaviour to instantiate a standard container ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Problem with STL vector and abstract class
    ... In article, Marcos Nunes ... >I am trying to understand why this doesn't compile. ... >an abstract class, and make a vector of them, as I show below. ... To put objects in a container they must be copy constructable (abstract ...
    (alt.comp.lang.learn.c-cpp)
  • Re: kernel 2.6.1 and cdrecord on ATAPI bus
    ... > I believe that you will find that you have to compile for 2.6 on a ... This is free software; see the source for copying conditions. ... Report bugs using the `glibcbug' script to. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)