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 241470 Details for
Bug 429906
[compiler][null] Array initializations not handled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
WIP Patch
patch.patch (text/plain), 4.21 KB, created by
shankha banerjee
on 2014-04-01 10:46:22 EDT
(
hide
)
Description:
WIP Patch
Filename:
MIME Type:
Creator:
shankha banerjee
Created:
2014-04-01 10:46:22 EDT
Size:
4.21 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java >index ffe997b..f300d8c 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010, 2014 GK Software AG and others. >+ * Copyright (c) 2010, 2014 GK Software AG, IBM and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7102,4 +7102,28 @@ public void testBug430084() { > "Return type for the method is missing\n" + > "----------\n"); > } >+ >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=429906 >+//[compiler][null] Array initializations not handled >+public void test429906() { >+ Map customOptions = getCompilerOptions(); >+ String code = >+ "import org.eclipse.jdt.annotation.*;\n" + >+ "@NonNullByDefault\n" + >+ "public class X {\n" + >+ " int[] a;\n" + >+ " int[] d = { 2 };\n" + >+ " X() {\n" + >+ " a = new int[0];\n" + >+ " foo(a);\n" + >+ " foo(d);\n" + >+ " int[] b = new int[0];\n" + >+ " foo(b);\n" + >+ " int [] c = { 2 };\n" + >+ " foo(c);\n" + >+ " }\n" + >+ " void foo(int [] b) {}\n" + >+ "}\n"; >+ runConformTestWithLibs(new String [] { "X.java", code }, customOptions, ""); >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java >index 656c770..3bd70f9 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java >@@ -240,4 +240,12 @@ public class ArrayAllocationExpression extends Expression { > public Annotation[][] getAnnotationsOnDimensions() { > return this.annotationsOnDimensions; > } >+ >+ public int nullStatus(FlowInfo flowInfo, FlowContext flowContext) { >+ if (this.dimensions.length != 1 && this.annotationsOnDimensions == null) >+ return FlowInfo.POTENTIALLY_NON_NULL; >+ >+ // Please see Expression#nullStatus >+ return FlowInfo.NON_NULL; >+ } > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java >index 73e60a4..da91c02 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2013, 2014 GK Software AG and others. >+ * Copyright (c) 2013, 2014 GK Software AG, IBM and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -128,7 +128,14 @@ public class NullAnnotationMatching { > if (requiredType.dimensions() == providedType.dimensions()) { > long[] providedDimsTagBits = ((ArrayBinding)providedType).nullTagBitsPerDimension; > if (providedDimsTagBits == null) { >- severity = 1; // required is annotated, provided not, need unchecked conversion >+ for (int i=0; i <=dims; i++) { >+ long requiredBits = validNullTagBits(requiredDimsTagBits[i]); >+ if (i > 0) >+ nullStatus = -1; >+ severity = Math.max(severity, computeNullProblemSeverity(requiredBits, 0, nullStatus, strict)); >+ if (severity == 2) >+ return NullAnnotationMatching.NULL_ANNOTATIONS_MISMATCH; >+ } > } else { > for (int i=0; i<=dims; i++) { > long requiredBits = validNullTagBits(requiredDimsTagBits[i]);
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 429906
:
241470
|
241501
|
241505