Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 206766 Details for
Bug 359284
Unnecessary checkast from null
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix + regression tests
HEAD--Fixed-bug-359284-Unnecessary-checkast-from-nul.patch (text/plain), 5.21 KB, created by
Ayushman Jain
on 2011-11-10 04:25:58 EST
(
hide
)
Description:
proposed fix + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-11-10 04:25:58 EST
Size:
5.21 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java >index cef41ac..c7c9427 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java >@@ -2374,6 +2374,54 @@ > "SUCCESS" > ); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=359284 >+// Verify that checkcast is emitted for a cast expression. >+public void test061b() throws Exception { >+ String source = >+ "public class X {\n" + >+ "public X() {\n" + >+ " Object[] x = (Object[])null;\n" + >+ "}\n" + >+ "}\n"; >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ source >+ }, >+ "" >+ ); >+ String expectedOutput = >+ "public class X {\n" + >+ " \n" + >+ " // Method descriptor #6 ()V\n" + >+ " // Stack: 1, Locals: 2\n" + >+ " public X();\n" + >+ " 0 aload_0 [this]\n" + >+ " 1 invokespecial java.lang.Object() [8]\n" + >+ " 4 aconst_null\n" + >+ " 5 checkcast java.lang.Object[] [10]\n" + >+ " 8 astore_1 [x]\n" + >+ " 9 return\n" + >+ " Line numbers:\n" + >+ " [pc: 0, line: 2]\n" + >+ " [pc: 4, line: 3]\n" + >+ " [pc: 9, line: 4]\n" + >+ " Local variable table:\n" + >+ " [pc: 0, pc: 10] local: this index: 0 type: X\n" + >+ " [pc: 9, pc: 10] local: x index: 1 type: java.lang.Object[]\n" + >+ "}"; >+ File f = new File(OUTPUT_DIR + File.separator + "X.class"); >+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); >+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); >+ int index = result.indexOf(expectedOutput); >+ if (index == -1 || expectedOutput.length() == 0) { >+ System.out.println(Util.displayString(result, 3)); >+ } >+ if (index == -1) { >+ assertEquals("Wrong contents", expectedOutput, result); >+ } >+} > public static Class testClass() { > return CastTest.class; > } >diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html >index 68e92aa..594de69 100644 >--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html >+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html >@@ -52,7 +52,9 @@ > <h2>What's new in this drop</h2> > > <h3>Problem Reports Fixed</h3> >-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=361441">361441</a> >+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=359284">359284</a> >+Unnecessary checkast from null >+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=361441">361441</a> > Error in JDT Core during AST creation > <br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=363293">363293</a> > resource leaks in org.eclipse.jdt.compiler.tool.tests >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >index b11e476..2d0066b 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >@@ -135,9 +135,8 @@ > this.initialization.generateCode(currentScope, codeStream, true); > // 26903, need extra cast to store null in array local var > if (this.binding.type.isArrayType() >- && (this.initialization.resolvedType == TypeBinding.NULL // arrayLoc = null >- || ((this.initialization instanceof CastExpression) // arrayLoc = (type[])null >- && (((CastExpression)this.initialization).innermostCastedExpression().resolvedType == TypeBinding.NULL)))){ >+ && ((this.initialization instanceof CastExpression) // arrayLoc = (type[])null >+ && (((CastExpression)this.initialization).innermostCastedExpression().resolvedType == TypeBinding.NULL))){ > codeStream.checkcast(this.binding.type); > } > codeStream.store(this.binding, false); >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >index a2cdd89..d625d5b 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >@@ -352,9 +352,8 @@ > } > // 26903, need extra cast to store null in array local var > if (localBinding.type.isArrayType() >- && (assignment.expression.resolvedType == TypeBinding.NULL // arrayLoc = null >- || ((assignment.expression instanceof CastExpression) // arrayLoc = (type[])null >- && (((CastExpression)assignment.expression).innermostCastedExpression().resolvedType == TypeBinding.NULL)))){ >+ && ((assignment.expression instanceof CastExpression) // arrayLoc = (type[])null >+ && (((CastExpression)assignment.expression).innermostCastedExpression().resolvedType == TypeBinding.NULL))){ > codeStream.checkcast(localBinding.type); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 359284
:
205874
|
205875
| 206766