-
Enhancement
-
Resolution: Won't Fix
-
P5
-
None
-
6
-
generic
-
solaris_8
Date: Wed, 21 Apr 2004 10:17:57 -0700
From: Neal Gafter <###@###.###>
Subject: Cdiff TransTypes.java (no redundant cast)
It turns out that this code will never cause the creation of a redundant cast in
the bytecode. That's because we're forcing the type of the expression to the
target type of the cast. That means that the outer cast will always be seen by
the code generator as redundant.
However, that means we can probably simplify this method to
public void visitTypeCast(TypeCast tree) {
result = translate(tree.expr, erasure(tree.type));
}
*** 5035001/src/share/classes/com/sun/tools/javac/comp/TransTypes.java- Wed Apr 21 00:09:49 2004
--- TransTypes.java Tue Apr 20 23:58:57 2004
*** 1,7 ****
/**
! * @(#)TransTypes.java 1.71 04/04/15
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
* Use and Distribution is subject to the Java Research License available
--- 1,7 ----
/**
! * @(#)TransTypes.java 1.72 04/04/20
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
* Use and Distribution is subject to the Java Research License available
*** 553,565 ****
}
public void visitTypeCast(TypeCast tree) {
tree.clazz = translate(tree.clazz, null);
tree.type = erasure(tree.type);
! tree.expr = translate(tree.expr,
! tree.expr.type.isPrimitive() == tree.type.isPrimitive()
! ? null : tree.type);
result = tree;
}
public void visitTypeTest(TypeTest tree) {
tree.expr = translate(tree.expr, null);
--- 553,563 ----
}
public void visitTypeCast(TypeCast tree) {
tree.clazz = translate(tree.clazz, null);
tree.type = erasure(tree.type);
! tree.expr = translate(tree.expr, tree.type);
result = tree;
}
public void visitTypeTest(TypeTest tree) {
tree.expr = translate(tree.expr, null);
From: Neal Gafter <###@###.###>
Subject: Cdiff TransTypes.java (no redundant cast)
It turns out that this code will never cause the creation of a redundant cast in
the bytecode. That's because we're forcing the type of the expression to the
target type of the cast. That means that the outer cast will always be seen by
the code generator as redundant.
However, that means we can probably simplify this method to
public void visitTypeCast(TypeCast tree) {
result = translate(tree.expr, erasure(tree.type));
}
*** 5035001/src/share/classes/com/sun/tools/javac/comp/TransTypes.java- Wed Apr 21 00:09:49 2004
--- TransTypes.java Tue Apr 20 23:58:57 2004
*** 1,7 ****
/**
! * @(#)TransTypes.java 1.71 04/04/15
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
* Use and Distribution is subject to the Java Research License available
--- 1,7 ----
/**
! * @(#)TransTypes.java 1.72 04/04/20
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
* Use and Distribution is subject to the Java Research License available
*** 553,565 ****
}
public void visitTypeCast(TypeCast tree) {
tree.clazz = translate(tree.clazz, null);
tree.type = erasure(tree.type);
! tree.expr = translate(tree.expr,
! tree.expr.type.isPrimitive() == tree.type.isPrimitive()
! ? null : tree.type);
result = tree;
}
public void visitTypeTest(TypeTest tree) {
tree.expr = translate(tree.expr, null);
--- 553,563 ----
}
public void visitTypeCast(TypeCast tree) {
tree.clazz = translate(tree.clazz, null);
tree.type = erasure(tree.type);
! tree.expr = translate(tree.expr, tree.type);
result = tree;
}
public void visitTypeTest(TypeTest tree) {
tree.expr = translate(tree.expr, null);