### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java,v retrieving revision 1.55 diff -u -r1.55 CompoundAssignment.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java 27 Jun 2008 16:03:55 -0000 1.55 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java 11 Nov 2008 23:30:46 -0000 @@ -153,8 +153,8 @@ return null; } if (this.operator == PLUS){ - if(lhsID == T_JavaLangObject) { - // += is illegal (39248) + if(lhsID == T_JavaLangObject && (scope.compilerOptions().complianceLevel < ClassFileConstants.JDK1_7)) { + // += is illegal (39248) for compliance < 1.7 scope.problemReporter().invalidOperator(this, lhsType, expressionType); return null; } else { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java,v retrieving revision 1.74 diff -u -r1.74 TestAll.java --- src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java 27 Jun 2008 16:04:45 -0000 1.74 +++ src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java 11 Nov 2008 23:30:47 -0000 @@ -155,6 +155,7 @@ tests_1_7.addAll(since_1_4); tests_1_7.addAll(since_1_5); tests_1_7.addAll(since_1_6); + tests_1_7.add(AssignmentTest_1_7.class); // Reset forgotten subsets tests TestCase.TESTS_PREFIX = null; TestCase.TESTS_NAMES = null; Index: src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java =================================================================== RCS file: src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java diff -N src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest_1_7.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2005, 2008 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.util.Map; + +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +import junit.framework.Test; + +public class AssignmentTest_1_7 extends AbstractRegressionTest { + +public AssignmentTest_1_7(String name) { + super(name); +} +protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportPotentialNullReference, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR); + options.put(CompilerOptions.OPTION_ReportNoEffectAssignment, CompilerOptions.ERROR); + return options; +} +// Static initializer to specify tests subset using TESTS_* static variables +// All specified tests which does not belong to the class are skipped... +static { +// TESTS_NAMES = new String[] { "test000" }; +// TESTS_NUMBERS = new int[] { 61 }; +// TESTS_RANGE = new int[] { 11, -1 }; +} +public static Test suite() { + return buildMinimalComplianceTestSuite(testClass(), F_1_7); +} +/* + * no effect assignment bug + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=27235 + */ +public void test001() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " Object o = new X();\n" + + " String s = \"ESS\";\n" + + " o += s;\n" + + " System.out.println(o);\n" + + " }\n" + + " public String toString() {\n" + + " return \"SUCC\";\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} +public static Class testClass() { + return AssignmentTest_1_7.class; +} +}