diff options
| author | Andrew Clement | 2013-08-07 10:13:17 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2013-08-07 10:13:17 +0000 |
| commit | fa4cf904b1d5690e02fc0246dbc8bc14a58e5d04 (patch) | |
| tree | 592004245be6ba09c48e687cc2c394ec791686ad | |
| parent | 8444b8c64dbb6b525eac8faf90c22961ce196392 (diff) | |
| download | eclipse.jdt.core-fa4cf904b1d5690e02fc0246dbc8bc14a58e5d04.tar.gz eclipse.jdt.core-fa4cf904b1d5690e02fc0246dbc8bc14a58e5d04.tar.xz eclipse.jdt.core-fa4cf904b1d5690e02fc0246dbc8bc14a58e5d04.zip | |
Fix for Bug 409247 - [1.8][compiler] Verify error with code allocating
multidimensional array.
Signed-off-by: Andrew Clement <aclement@gopivotal.com>
4 files changed, 26 insertions, 9 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java index 12054919d2..c8a31318ac 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation 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 @@ -8,6 +8,8 @@ * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for Bug 331872 - [compiler] NPE in Scope.createArrayType when attempting qualified access from type parameter + * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for + * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; import java.io.File; @@ -575,4 +577,19 @@ public void test018() throws Exception { "The method foo(Object[]) is undefined for the type X<p>\n" + "----------\n"); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=409247 - [1.8][compiler] Verify error with code allocating multidimensional array +public void test019() throws Exception { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " X [][][] x = new X[10][10][];\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); +} } 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 47cdc77af5..418be155bb 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 @@ -17,7 +17,7 @@ * bug 403147 - [compiler][null] FUP of bug 400761: consolidate interaction between unboxing, NPE, and deferred checking * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) - * + * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -79,7 +79,7 @@ public class ArrayAllocationExpression extends Expression { codeStream.newArray(this.type, this.annotationsOnDimensions, (ArrayBinding)this.resolvedType); } else { // Multi-dimensional array - codeStream.multianewarray(this.type, this.resolvedType, this.dimensions.length, this.annotationsOnDimensions); + codeStream.multianewarray(this.type, this.resolvedType, explicitDimCount, this.dimensions.length, this.annotationsOnDimensions); } if (valueRequired) { codeStream.generateImplicitConversion(this.implicitConversion); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java index f6715da8a2..b44dd65eb1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java @@ -18,6 +18,7 @@ * Bug 405066 - [1.8][compiler][codegen] Implement code generation infrastructure for JSR335 * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) + * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array *******************************************************************************/ package org.eclipse.jdt.internal.compiler.codegen; @@ -5707,14 +5708,11 @@ public void monitorexit() { this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_monitorexit; } -public void multianewarray(TypeBinding typeBinding, int dimensions) { - this.multianewarray(null, typeBinding, dimensions, null); -} - public void multianewarray( TypeReference typeReference, TypeBinding typeBinding, int dimensions, + int declaredDimensions, Annotation [][] annotationsOnDimensions) { this.countLabels = 0; this.stackDepth += (1 - dimensions); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java index e1fb841c24..3cc928cbe9 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/TypeAnnotationCodeStream.java @@ -13,6 +13,7 @@ * IBM Corporation - initial API and implementation * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work) + * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array *******************************************************************************/ package org.eclipse.jdt.internal.compiler.codegen; @@ -60,11 +61,12 @@ public class TypeAnnotationCodeStream extends StackMapFrameCodeStream { TypeReference typeReference, TypeBinding typeBinding, int dimensions, + int declaredDimensions, Annotation [][] annotationsOnDimensions) { if (typeReference != null && (typeReference.bits & ASTNode.HasTypeAnnotations) != 0) { - addAnnotationContext(typeReference, this.position, AnnotationTargetTypeConstants.NEW, annotationsOnDimensions, dimensions); + addAnnotationContext(typeReference, this.position, AnnotationTargetTypeConstants.NEW, annotationsOnDimensions, declaredDimensions); } - super.multianewarray(typeReference, typeBinding, dimensions, annotationsOnDimensions); + super.multianewarray(typeReference, typeBinding, dimensions, declaredDimensions, annotationsOnDimensions); } public void new_(TypeReference typeReference, TypeBinding typeBinding) { |
