Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33361
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Steven Simpson <ss@my.domain.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: about class dependancies |
| Date | Thu, 17 Dec 2015 08:39:07 +0000 |
| Organization | A noiseless patient Spider |
| Lines | 71 |
| Message-ID | <bu8akc-reu.ln1@s.simpson148.btinternet.com> (permalink) |
| References | <565f816b$0$3054$426a74cc@news.free.fr> <77dedcc2-f07c-4234-9b5c-22993b04c6d1@googlegroups.com> <565f9194$0$4565$426a74cc@news.free.fr> <31f29220-8f05-42a4-b62e-59eec378b924@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | mx02.eternal-september.org; posting-host="1d47646cb42a54284bd577b6100d82bd"; logging-data="23813"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IurUTr9vMRnftdBFS00lAF6x92XJpMhQ=" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
| In-Reply-To | <31f29220-8f05-42a4-b62e-59eec378b924@googlegroups.com> |
| Cancel-Lock | sha1:EF/gI05VUK41XXzvWs75f1zJQYY= |
| Xref | csiph.com comp.lang.java.programmer:33361 |
Show key headers only | View raw
On 17/12/15 02:27, Lew wrote:
> On Wednesday, December 2, 2015 at 4:49:41 PM UTC-8, regis wrote:
>> On 12/03/15 01:32, Lew wrote:
>>> On Wednesday, December 2, 2015 at 3:40:46 PM UTC-8, regis wrote:
>>>> let say we have some public class A
>>>> that depends on some public class B, e.g.:
>>>>
>>>> ====
>>>> // B.java
>>>> public class B {
>>>> public int f(int n) { return 2*n; }
>>>> }
>>>> ====
>>>> // A.java
>>>> public class A {
>>>> public static void main (String[] args) {
>>>> B b= new B ();
>>>> System.out.println (b.f(5));
>>>> }
>>>> }
>>>> ====
>>>> $ javac A.java B.java
>>>> $ java A
>>>> 10
>>>> ====
>>>>
>>>> Then let say class B changes (with signature of f() unchanged), e.g.:
>>>>
>>>> ====
>>>> // B.java, changed
>>>> public class B {
>>>> int lambda= 10;
>>>> public int f(int n) { return lambda*n; }
>>>> }
>>>> ====
>>>>
>>>> Finally, we update file B.class, but not file A.class,
>>>>
>>>> ====
>>>> $ javac B.java # but not A.java
>>>> $ java A
>>>> 50
>>>> ====
>>>>
>>>> It seems to work, but is it guaranteed ?
>>>> or should file A.class still be updated ?
>>
>>> The Java compiler "javac" is smart enough to resolve many dependencies, including the one you note here.
>>> However, this would not work if 'lambda' (*terrible* name for that variable!) were made 'final', and therefore a constant variable.
>>
>> It still seems to work if it is made final...
>>
>> // B.java, changed
>> public class B {
>> final int multiplier= 1000;
>> public int f(int n) { return multiplier*n; }
>> }
>> ====
>> $ javac B.java # but not A.java
>> $ java A
>> 5000
> That isn't what I meant. I meant if you recompile 'A' but not 'B" then you don't pick up the change in 'B'. What you did was recompile 'B' and run 'A'. I had misread your example.
I don't get it. A.java refers to B, so compiling A.java will also
compile B.java as an implicit class, unless you have implicit
compilation turned off.
--
ss at comp dot lancs dot ac dot uk
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
about class dependancies regis <regis.barbanchon@free.fr> - 2015-12-03 00:40 +0100
Re: about class dependancies Lew <lewbloch@gmail.com> - 2015-12-02 16:32 -0800
Re: about class dependancies regis <regis.barbanchon@free.fr> - 2015-12-03 01:49 +0100
Re: about class dependancies regis <regis.barbanchon@free.fr> - 2015-12-03 02:26 +0100
Re: about class dependancies Arne Vajhøj <arne@vajhoej.dk> - 2015-12-02 21:55 -0500
Re: about class dependancies Arne Vajhøj <arne@vajhoej.dk> - 2015-12-02 21:58 -0500
Re: about class dependancies Steven Simpson <ss@my.domain.invalid> - 2015-12-03 15:15 +0000
Re: about class dependancies Arne Vajhøj <arne@vajhoej.dk> - 2015-12-03 19:49 -0500
Re: about class dependancies Lew <lewbloch@gmail.com> - 2015-12-16 18:27 -0800
Re: about class dependancies Steven Simpson <ss@my.domain.invalid> - 2015-12-17 08:39 +0000
Re: about class dependancies Lew <lewbloch@gmail.com> - 2015-12-17 13:36 -0800
Re: about class dependancies Mike Amling <mamling@chaff.us> - 2015-12-21 08:29 -0600
Re: about class dependancies regis <regis.barbanchon@free.fr> - 2015-12-03 02:07 +0100
Re: about class dependancies Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-03 08:06 -0500
csiph-web