Opera OpenOffice.org Jabber Psi jabber://llama@mordax.com
Uhm, volgens mij wel.. Had gisteren nl een static final int van waarde veranderd, maar ik moest echt de class die hm gebruikte geheel opnieuw compilen (dus .class file weg en dan weer compilen, want het werd niet opgemerkt).
Dus opzich is de Java compiler best slim, maar ook weer niet (kan trouwens ook aan codeguide gelegen hebben hoor)
Dus opzich is de Java compiler best slim, maar ook weer niet (kan trouwens ook aan codeguide gelegen hebben hoor)
java compiler ook (althans volgens artikel op javaworld).
De Java Compiler doet nog wel iets
.
Een 2 in 1 test:
Je ziet hier dus een if statement met een constante false en een CONST gebruik, waarbij hopelijk constante propagatie wordt gebruikt.
We halen jad eroverheen:
Netjes denk ik zo he?
.
Zelfs de optelling met de int wordt al door de compiler gedaan
.
Een 2 in 1 test:
code:
1
2
3
4
5
6
7
8
9
10
11
12
| public class OptTest {
private static final boolean DEBUG = false;
private static final int CONST = 0;
public void blaat() {
if(DEBUG) {
System.out.println("Debug");
}
System.out.println("CONST: " + CONST);
}
} |
Je ziet hier dus een if statement met een constante false en een CONST gebruik, waarbij hopelijk constante propagatie wordt gebruikt.
We halen jad eroverheen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3)
// Source File Name: OptTest.java
import java.io.PrintStream;
public class OptTest
{
public OptTest()
{
}
public void blaat()
{
System.out.println("CONST: 0");
}
private static final boolean DEBUG = false;
private static final int CONST = 0;
} |
Netjes denk ik zo he?
Zelfs de optelling met de int wordt al door de compiler gedaan
Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment
Nog even een leuker voorbeeld:
Jad:
en nog eentje:
tada:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| public class OptTest {
private static final boolean DEBUG = false;
private static final int CONST = 0;
public void blaat() {
if(DEBUG) {
System.out.println("Debug");
}
if(DEBUG || CONST == 0) {
System.out.println("CONST: " + CONST);
}
}
} |
Jad:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3)
// Source File Name: OptTest.java
import java.io.PrintStream;
public class OptTest
{
public OptTest()
{
}
public void blaat()
{
System.out.println("CONST: 0");
}
private static final boolean DEBUG = false;
private static final int CONST = 0;
} |
en nog eentje:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| public class OptTest {
private static final boolean DEBUG = false;
private static final int CONST = 0;
public void blaat() {
if(DEBUG) {
System.out.println("Debug");
}
if(DEBUG || CONST == 1) {
System.out.println("CONST: " + CONST);
}
}
} |
tada:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3)
// Source File Name: OptTest.java
public class OptTest
{
public OptTest()
{
}
public void blaat()
{
}
private static final boolean DEBUG = false;
private static final int CONST = 0;
} |
Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment
Vermoede het zelf al, maar fijn om het zeker te weten.. thanx iedereen! 
Het lijkt erop dat de JAVA compiler final ongeveer het zelfde behandeld als #include in C (zoals in dat 2e voorbeeld te zien is)..
Het lijkt erop dat de JAVA compiler final ongeveer het zelfde behandeld als #include in C (zoals in dat 2e voorbeeld te zien is)..
Opera OpenOffice.org Jabber Psi jabber://llama@mordax.com
Pagina: 1