Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14875

Re: How are multiple Java files compiled together?

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: How are multiple Java files compiled together?
Date 2012-05-28 22:35 -0700
Organization albasani.net
Message-ID <jq1n6r$6fa$1@news.albasani.net> (permalink)
References (1 earlier) <jpudmj$m0h$1@dont-email.me> <19fc754b-0501-46dc-ac81-3589c708e004@googlegroups.com> <jpuqqg$md9$1@news.albasani.net> <jputnt$sea$1@dont-email.me> <vr97s717126jijtd0jl0hjq8h8c6urkufk@4ax.com>

Show all headers | View raw


Gene Wirchenko wrote:
> Knute Johnson wrote:
> [snip]
>
>> Did I mis-remember that or has it changed since version 4 or there
>> abouts?  I seem to remember a long thread here on this subject and I've
>> always erased all my .class files before every compilation to avoid it.
>>   Have I generated my own myth?

I live in the now. I don't know what you remember, nor how well, nor what changed.

>       Maybe, but I can believe you had a difficulty that needed clean
> compiles.

+1

>       I had a problem with jCreator where I was using code from a
> textbook on an assignment.  (Many of the exercises used textbook
> source code.)  I had to compile the textbook source code, but then
> subsequent compilations would fail claiming that the textbook source
> code was not valid Java code!  The solution^Whorrible kludge was to
> the delete the textbook source code used after the first compilation.

Or put it in it own JAR.

Or figure out why it went wrong and solve it from understanding.

>       When things like this happen, I am not surprised that people get
> shy.  I prefer clean, full compiles myself.

The Java compiler does the best it can to resolve dependencies. It can't cover 
a lot of scenarios, and it can really lose it over sometimes having source in 
the sourcepath and sometimes not. It treats constants (as the JLS defines 
them) differently from other immutable or mutable expressions.

Clean compiles are fine for your non-library (not in JARs) code and sometimes 
necessary. We're not supposed to behave by superstition, but clean compile is 
a prevalent and fairly harmless one.

Better protection is to organize your code into JARs, where you never compile 
upstream JARs except when you work on their projects explicitly.

I espouse full knowledge of the rules, but I struggle to stay up on the corner 
cases myself. I keep returning to study them, and discussions like this one 
help to elucidate them.

For dependencies beyond what javac can handle, we have Ant. That why we have Ant.

I am jaundiced by project after project after project where I've stepped in 
the build mess left by predecessors who created build systems by cult ritual. 
One of the worst was a "refactoring" of the build consigned to a contract 
company that claimed great expertise and tangled the ball of yarn even 
further. (That one used Maven, which complicated the repair process.)

Build and deployment procedures require even more professionalism, diligence 
and attention to detail than program code.

-- 
Lew


-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How are multiple Java files compiled together? Jason Kim <iamjsonkim@gmail.com> - 2012-05-27 15:48 -0700
  Re: How are multiple Java files compiled together? Knute Johnson <nospam@knutejohnson.com> - 2012-05-27 16:34 -0700
    Re: How are multiple Java files compiled together? Jason Kim <iamjsonkim@gmail.com> - 2012-05-27 16:47 -0700
      Re: How are multiple Java files compiled together? Lew <noone@lewscanon.com> - 2012-05-27 20:18 -0700
        Re: How are multiple Java files compiled together? Knute Johnson <nospam@knutejohnson.com> - 2012-05-27 21:08 -0700
          Re: How are multiple Java files compiled together? Gene Wirchenko <genew@ocis.net> - 2012-05-28 09:32 -0700
            Re: How are multiple Java files compiled together? Lew <noone@lewscanon.com> - 2012-05-28 22:35 -0700
              Re: How are multiple Java files compiled together? Gene Wirchenko <genew@ocis.net> - 2012-05-29 09:20 -0700
  Re: How are multiple Java files compiled together? Roedy Green <see_website@mindprod.com.invalid> - 2012-05-27 17:35 -0700
    Re: How are multiple Java files compiled together? Roedy Green <see_website@mindprod.com.invalid> - 2012-05-27 19:34 -0700
    Re: How are multiple Java files compiled together? Roedy Green <see_website@mindprod.com.invalid> - 2012-05-28 04:00 -0700
      Re: How are multiple Java files compiled together? Lew <noone@lewscanon.com> - 2012-05-28 22:56 -0700

csiph-web