f



Compiler mystery: Compiles classes that don't compile

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

/Martin

0
peeping_t (10)
2/28/2006 10:09:32 PM
comp.lang.java.help 13340 articles. 0 followers. Post Follow

3 Replies
867 Views

Similar Articles

[PageSpeed] 43

<peeping_t@hotmail.com> wrote in message 
news:1141164572.509560.238590@u72g2000cwu.googlegroups.com...
> 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 

0
owong (6177)
2/28/2006 10:17:14 PM
The previous programmer was most certainly using eclipse so thanks for
the explanation.
To me it seems to be a quite dangerous feature in eclipse.

/Martin

0
peeping_t (10)
3/1/2006 12:57:24 AM
<peeping_t@hotmail.com> wrote in message 
news:1141174644.601117.193250@i40g2000cwc.googlegroups.com...
>
> The previous programmer was most certainly using eclipse so thanks for
> the explanation.
> To me it seems to be a quite dangerous feature in eclipse.

    It is sometimes convenient to run a program even though it contains some 
compile errors. For example, a client is coming over, and you have to 
perform a demo, but one of your coworkers was in the middle of modifying 
some part of the application, and hasn't finished his changes. As long as 
you don't actually cause the code with errors to execute, the application 
appears to run just fine.

    - Oliver 

0
owong (6177)
3/16/2006 5:50:29 PM
Reply:

Similar Artilces:

Help - can't compile
I'm using Ant to compile a set of proprietary frameworks. I think I have set up CLASSPATH etc correctly, but I keep getting the following error when trying to build. Anyone have any ideas of what I should try? Thanks!! [ejbc] Compiler class: 'com.sun.tools.javac.Main', not found [ejbc] java.lang.ClassNotFoundException: com.sun.tools.javac.Main [ejbc] at java.net.URLClassLoader$1.run(URLClassLoader.java:199) [ejbc] at java.security.AccessController.doPrivileged(Native Method) [ejbc] at java.net.URLClassLoader.findClass(URLClassLoader.java:187) [e...

Compiled or not compiled
I need to distinguish between two situations: one when a Matlab function is run from Matlab command window and the other one when it is run in compiled mode. Any ideas how to do this? Thanks Tomy Duby "Tomy Duby" <tomy.duby@agilent.com> wrote in message news:idq8q8$85k$1@fred.mathworks.com... > I need to distinguish between two situations: one when a Matlab function > is run from Matlab command window and the other one when it is run in > compiled mode. > Any ideas how to do this? HELP ISDEPLOYED. -- Steve Lord slord@mathworks.com comp.s...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

which compiler compiled?
Is there a way I can tell which compiler compiled an executable? I looked at the file with a hex editor and didn't see anything obvious. Lawrence "Lawrence" <just4me@nowhere.com> writes: > Is there a way I can tell which compiler compiled an executable? Yes with some compilers and some executable formats. E.g. on HP-UX for PA-RISC: $ aCC leak.C $ odump -compunit a.out ... 6 0 ANSI C++ leak.C /tmp ctcom options = -inst compiletime -diags 523 -inline_power 1 -longbranch 2 -unique_strings on -cachesize 256 B...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

Compiling Compiler
Hi there, I need some advice/opinion of the experts out there regarding compilers. I have sun cc compiler that supports 64 bit environment. Now, I compile ACK using this compiler.This should give a compiler that supports 64bit environment. Since the output files are in Solaris format, I compile the ACK source *once again* using the just compiled ACK compiler so that I get Minix object and binary files. Now my questions is that does this 2nd version of ACK be able to produce true 64bit code? Sanky wrote: > Hi there, > > I need some advice/opinion of the experts out there regarding...

Compile or not compile?
There's something that sometimes in while it bores me a little bit. How do I know if I need to compile a function/procedure or it will be able to compile "on fly". At the beginning I thought this was related to the paths idl "knew", but this happens for two functions/routines in the same directory. Can someone tell when a function can be runned without be compile? Nuno Oliveira wrote: > There's something that sometimes in while it bores me a little bit. How > do I know if I need to compile a function/procedure or it will be able > to compile &quo...

FAQ: I don't have a C compiler on my system. How can I compile perl?
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 2.3: I don't have a C compiler on my system. How can I compile perl? Since you don't have a C compiler, you're doomed and your vendor should be sacrificed to the Sun gods. But that doesn't help you. What you need to do is get a binary version of gcc ...

FAQ 2.3 I don't have a C compiler on my system. How can I compile perl?
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 2.3: I don't have a C compiler on my system. How can I compile perl? Since you don't have a C compiler, you're doomed and your vendor should be sacrificed to the Sun gods. But that doesn't help you. What you need to do is get a binary version of gcc f...

compiling Qt .... compiling Qt ....compiling Qt.... compiling Qt
I got myself new kernel from kernel.org... make xconfig needs Qt (new system). So I got new Qt source this afternoon. It is still compiling.... Who said MS is bloat has not done this. What does Qt do? Dunno, how about xforms for xconfig? On Thu, 02 Feb 2006 19:18:09 +0000, Jan Panteltje wrote: > Dunno, how about xforms for xconfig? Why not curses based? menuform -- Hilsen/Regards Michael Rasmussen http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917 On a sunny day (Thu, 02 Feb 2006 21:55:33 +0100) it happened Michael Rasmussen <mir@miras.or...

FAQ 2.3 I don't have a C compiler on my system. How can I compile perl? #2
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 2.3: I don't have a C compiler on my system. How can I compile perl? Since you don't have a C compiler, you're doomed and your vendor should be sacrificed to the Sun gods. But that doesn't help you. What you need to do is get a binary version of gcc f...

FAQ 2.3 I don't have a C compiler on my system. How can I compile perl? #3
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 2.3: I don't have a C compiler on my system. How can I compile perl? Since you don't have a C compiler, you're doomed and your vendor should be sacrificed to the Sun gods. But that doesn't help you. What you need to do is get a binary version of gcc f...

don't know how to compile a java program w/ Java 1.0.5_2
I don't know how to compile a '.java' file on WinXP Home Servicepack 2 I don't have Microsoft's JVM. Can someone help. TheGuild42@gmail.com wrote: > I don't know how to compile a '.java' file on WinXP Home Servicepack 2 > I don't have Microsoft's JVM. > > Can someone help. Just download the JDK from java.sun.com and use javac from the bin directory to compile your source. JDK 1.4: http://java.sun.com/j2se/1.4.2/download.html JDK 1.5: http://java.sun.com/j2se/1.5.0/download.jsp JW ...

If Mel really didn't approve of compilers and if refused to use an "optimizing assembler", existed others developers that really didn't approve of compilers and if refused to use an "optimizing assemb
This is the last topic that I post about the history of machine language using the Google Translate. According Ed Nather in The Story of Mel, this is part of the history of machine language: "The Story of Mel This was posted to Usenet by its author, Ed Nather (<nather@astro.as.utexas.edu>), on May 21, 1983. A recent article devoted to the macho side of programming made the bald and unvarnished statement: Real Programmers write in FORTRAN. Maybe they do now, in this decadent era of Lite beer, hand calculators, and "user-friendly" software but ba...

Very strange behavior when compiling in 'cc' vs. compiling in 'gcc'
Hi All, I'm compiling some c files on AIX 5.1 under power 604. There include headers of my 'c' files are as follows: #include <math.h> #include<stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <malloc.h> As a result, the application is compiled using the flags '-lm' and '-lc' in the Makefile, when only the compiler name is being changed in the Makefile ('gcc' or 'cc'). No optimizations are being used. The command 'gcc -v' yields: Reading specs from /usr/bin/../lib/gcc-lib/powerp...

program that compiles in C compiler but not in C++ compiler
Hi, I need a small program that compiles in C compiler but not in C++ compiler. Thx in advans, Karthik Balaguru KBG <karthik.balaguru@lntinfotech.com> wrote: > I need a small program that compiles in C compiler but not in C++ > compiler. No problem, just send $10 to paypal@zevv.nl and I'll do your homework for you. -- :wq ^X^Cy^K^X^C^C^C^C KBG said: > Hi, > > I need a small program that compiles in C compiler but not in C++ > compiler. Can you think of any syntactic differences between C and C++? For example, what about keywords? They are very, very sen...

don't get JPE (Java Python Extension) compiled.
Hi people! I want to compile the Java Python Extension which I downloaded through CVS "http://jpe.cvs.sourceforge.net/jpe/" Building JPE by bootstrapping the makefile system with the cmd: "python makefile.py" from the top source directory. I receive the following error message: working in </home/tamer/JPE/jpe> use make command <make> <env make -f config.mk> ksh /home/tamer/JPE/libplus/bin/pybatch.ksh /home/tamer/JPE/libplus /usr/bin/python -c "import devkit; devkit.pythonexe = None; import imp; imp.load_source( 'makefile', 'makefile.p...

My LogGenerator.java won't compile - too many errors
[code] package ppowell; import java.io.IOException; /** * Interface * * @version JDK 1.4 * @author Phil Powell * @package PPOWELL */ public interface Loggable { String logFileName = ""; public String getLogFileName(); public void setLogFileName(); public void deleteLog() throws IOException; public void doLog() throws IOException; } [/code] [code] package ppowell; import java.io.*; import java.util.*; /** * Public implementation for LogGenerator to do logging. Singleton Design Pattern * * @version JSDK 1.4 * @author Phil Powell * @package PPOWELL */ publi...

Can't compile djgpp cross-compiler on GNU/Linux
Greetings. I'm unable to compile djgpp (gcc-3.4.2) as a cross-compiler on my SuSE i686-pc-linux-gnu system running gcc-3.3.2. As I'm not sure if this is a gcc bug or a djgpp bug, I have reported it on the gcc Bugzilla and am posting a CC here. Regards, Tristan Date: 30 Sep 2004 18:57:05 -0000 From: "psychonaut at nothingisreal dot com" <gcc-bugzilla@gcc.gnu.org> To: psychonaut@nothingisreal.com Subject: [Bug libstdc++/17755] New: Can't compile djgpp cross-compiler I am trying to compile gcc as a cross-compiler for MS-DOS/Windows. I am essentially using the sam...

Can't compile flames.m with Compiler 4.1
Running Matlab R14 SP1 on XP SP2, Thinkpad A31p, when I try to compile flames.m as a standalone .exe using the Compiler v 4.1, the app window opens momentarily, then immediately closes. MCR was installed properly. I can create executables from Hello.m and magicsquare.m with no problem. I get no errors or warnings during compilation of flames. Any ideas on where to begin debugging? Thanks. I can't reproduce this on my machine. Do you get no error messages? No output text at all? Try putting some disp statements in flames.m to see if execution ever reaches the M-file. Is flames.mat ...

specialized constructor won't compile (MS C++ compiler)
Hello, the following code doesn't compile, and I don't have no clue why: class Test { template<typename T> Test(T value) { } }; template<> Test::Test<bool>(bool value) { } // Error ! This yields in the last line of this example: error C2143: syntax error : missing ';' before '<' I tried this, too: class Test { template<typename T> Test(T value) { } template<> Test::Test<bool>(bool value) { } // Error ! // The scope operator is use here, becaus I want a specialization // of the functi...

pgsql-server: We don't use java in our compiles anymore so remove the
Log Message: ----------- We don't use java in our compiles anymore so remove the filter test from pgtest. Modified Files: -------------- pgsql-server/src/tools: pgtest (r1.4 -> r1.5) (http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/tools/pgtest.diff?r1=1.4&r2=1.5) ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html ...

why it isn't compiled about "template< template<class> class T>"
Hi, all I find "template template" class cann't been compiled in VC6 but can ok in Redhat9. I write a test program like as: template< template<class> class T> class A { }; int main() { return 0; } compiling failed for message: D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions cannot nest D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations are only permitted at global or namespace scope D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error : unexpected type 'T' D:\my_projects\testcpp\main.cpp(5) : error C2143: ...

java tutorial no compiled 'class' files!
Hi I have the sun's java tutorial, which appears to have 'class' files for the applets in the examples (error dialog coming up!) Has anyone else having this problem? the version I have is dated November 3 2003. I have used the following code to find and compile the source code, it could have been written better I guess but does the job without errors! PS have a cup of tea watch TV while it compiles the source code usage java recurse directory/to/java/tutorial import java.io.*; import java.util.*; public class recurse { public static void main(String[] args) throws IOExceptio...

Web resources about - Compiler mystery: Compiles classes that don't compile - comp.lang.java.help

Resources last updated: 2/18/2016 11:04:33 PM