View | Details | Raw Unified | Return to bug 341475
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +6 lines)
Lines 7328-7334 Link Here
7328
			&& field.isStatic()
7328
			&& field.isStatic()
7329
			&& field.isFinal()
7329
			&& field.isFinal()
7330
			&& TypeBinding.LONG == field.type) {
7330
			&& TypeBinding.LONG == field.type) {
7331
				return; // do not report unused serialVersionUID field
7331
		ReferenceBinding referenceBinding = field.declaringClass;
7332
		if (referenceBinding != null) {
7333
			if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) {
7334
				return; // do not report unused serialVersionUID field for class that implements Serializable
7335
			}
7336
		}
7332
	}
7337
	}
7333
	if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
7338
	if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name)
7334
			&& field.isStatic()
7339
			&& field.isStatic()
(-)src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java (-1 / +48 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
2
 * Copyright (c) 2006, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-21 Link Here
16
16
17
import java.util.Map;
17
import java.util.Map;
18
18
19
import org.eclipse.jdt.core.JavaCore;
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
21
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
20
22
21
import junit.framework.Test;
23
import junit.framework.Test;
Lines 207-210 Link Here
207
			""
209
			""
208
		);
210
		);
209
}
211
}
212
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=341475
213
public void test011() {
214
	Map options = getCompilerOptions();
215
	options.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR);
216
	this.runNegativeTest(
217
		new String[] {
218
			"X.java",
219
			"public class X {\n" +
220
			"	private static final long serialVersionUID = 1L;\n" +
221
			"}"
222
		},
223
		"----------\n" + 
224
		"1. ERROR in X.java (at line 2)\n" + 
225
		"	private static final long serialVersionUID = 1L;\n" + 
226
		"	                          ^^^^^^^^^^^^^^^^\n" + 
227
		"The value of the field X.serialVersionUID is not used\n" + 
228
		"----------\n",
229
		null,
230
		true,
231
		options
232
	);
233
}
234
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=341475
235
public void test012() {
236
	if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
237
	Map options = getCompilerOptions();
238
	options.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR);
239
	this.runNegativeTest(
240
		new String[] {
241
			"X.java",
242
			"public class X<T> {\n" +
243
			"	private static final long serialVersionUID = 1L;\n" +
244
			"}"
245
		},
246
		"----------\n" + 
247
		"1. ERROR in X.java (at line 2)\n" + 
248
		"	private static final long serialVersionUID = 1L;\n" + 
249
		"	                          ^^^^^^^^^^^^^^^^\n" + 
250
		"The value of the field X<T>.serialVersionUID is not used\n" + 
251
		"----------\n",
252
		null,
253
		true,
254
		options
255
	);
256
}
210
}
257
}

Return to bug 341475