View | Details | Raw Unified | Return to bug 365437 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-2 / +147 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 47-53 Link Here
47
	// Static initializer to specify tests subset using TESTS_* static variables
47
	// Static initializer to specify tests subset using TESTS_* static variables
48
	// All specified tests which do not belong to the class are skipped...
48
	// All specified tests which do not belong to the class are skipped...
49
	static {
49
	static {
50
//		TESTS_NAMES = new String[] { "test293" };
50
//		TESTS_NAMES = new String[] { "testBug365437b" };
51
//		TESTS_NUMBERS = new int[] { 297 };
51
//		TESTS_NUMBERS = new int[] { 297 };
52
//		TESTS_RANGE = new int[] { 294, -1 };
52
//		TESTS_RANGE = new int[] { 294, -1 };
53
	}
53
	}
Lines 10148-10151 Link Here
10148
		"Bla cannot be resolved to a type\n" +
10148
		"Bla cannot be resolved to a type\n" +
10149
		"----------\n");
10149
		"----------\n");
10150
}
10150
}
10151
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437
10152
public void testBug365437a() {
10153
	Map customOptions = getCompilerOptions();
10154
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
10155
	String testFiles [] = new String[] {
10156
			"p/A.java",
10157
			"package p;\n" +
10158
			"import p1.*;\n" +
10159
			"public class A {\n" +
10160
			"	@p1.PreDestroy\n" +
10161
			"	private void foo1(){}\n" +
10162
			"	@PreDestroy\n" +
10163
			"	private void foo2(){}\n" +
10164
			"	@SuppressWarnings(\"null\")\n" +
10165
			"	@PostConstruct\n" +
10166
			"	private void foo1a(){}\n" +
10167
			"	@PostConstruct\n" +
10168
			"	private void foo2a(){}\n" +
10169
			"	@Deprecated" +
10170
			"	private void foo3(){}" +
10171
			"}\n",
10172
			"p1/PreDestroy.java",
10173
			"package p1;\n" +
10174
			"public @interface PreDestroy{}",
10175
			"p1/PostConstruct.java",
10176
			"package p1;\n" +
10177
			"public @interface PostConstruct{}"
10178
			};
10179
	String expectedErrorString = 
10180
			"----------\n" + 
10181
			"1. WARNING in p\\A.java (at line 8)\n" + 
10182
			"	@SuppressWarnings(\"null\")\n" + 
10183
			"	                  ^^^^^^\n" + 
10184
			"Unnecessary @SuppressWarnings(\"null\")\n" + 
10185
			"----------\n" + 
10186
			"2. ERROR in p\\A.java (at line 13)\n" + 
10187
			"	@Deprecated	private void foo3(){}}\n" + 
10188
			"	           	             ^^^^^^\n" + 
10189
			"The method foo3() from the type A is never used locally\n" + 
10190
			"----------\n";
10191
	runNegativeTest(
10192
			true,
10193
			testFiles,
10194
			null, 
10195
			customOptions,
10196
			expectedErrorString,
10197
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
10198
}
10199
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437
10200
public void testBug365437b() {
10201
	Map customOptions = getCompilerOptions();
10202
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
10203
	customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED);
10204
	customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull");
10205
	String testFiles [] = new String[] {
10206
			"A.java",
10207
			"import javax.annotation.*;\n" +
10208
			"public class A {\n" +
10209
			"	@javax.annotation.PreDestroy\n" +
10210
			"	private void foo1(){}\n" +
10211
			"	@PreDestroy\n" +
10212
			"	private void foo2(){}\n" +
10213
			"	@javax.annotation.Resource\n" +
10214
			"	private void foo1a(){}\n" +
10215
			"	@Resource\n" +
10216
			"	@p.NonNull\n" +
10217
			"	private Object foo2a(){ return new Object();}\n" +
10218
			"	@javax.annotation.PostConstruct\n" +
10219
			"	@Deprecated\n" +
10220
			"	private void foo3(){}\n" +
10221
			"	@p.NonNull\n" +
10222
			"	private Object foo3a(){ return new Object();}\n" +
10223
			"}\n",
10224
			"p/NonNull.java",
10225
			"package p;\n" +
10226
			"import static java.lang.annotation.ElementType.*;\n" +
10227
			"import java.lang.annotation.*;\n" +
10228
			"@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE})\n" +
10229
			"public @interface NonNull {\n" +
10230
			"}"
10231
			};
10232
	String expectedErrorString = 
10233
			"----------\n" + 
10234
			"1. ERROR in A.java (at line 16)\n" + 
10235
			"	private Object foo3a(){ return new Object();}\n" + 
10236
			"	               ^^^^^^^\n" + 
10237
			"The method foo3a() from the type A is never used locally\n" + 
10238
			"----------\n";
10239
	runNegativeTest(
10240
			true,
10241
			testFiles,
10242
			null, 
10243
			customOptions,
10244
			expectedErrorString,
10245
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
10246
}
10247
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437
10248
public void testBug365437c() {
10249
	if (this.complianceLevel < ClassFileConstants.JDK1_7) return;
10250
	Map customOptions = getCompilerOptions();
10251
	customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
10252
	String testFiles [] = new String[] {
10253
			"p/A.java",
10254
			"package p;\n" +
10255
			"import p1.*;\n" +
10256
			"public class A {\n" +
10257
			"	@p1.PreDestroy\n" +
10258
			"	private void foo1(){}\n" +
10259
			"	@PreDestroy\n" +
10260
			"	private void foo2(){}\n" +
10261
			"	@SuppressWarnings(\"null\")\n" +
10262
			"	@PostConstruct\n" +
10263
			"	private void foo1a(){}\n" +
10264
			"	@PostConstruct\n" +
10265
			"	private void foo2a(){}\n" +
10266
			"	@SafeVarargs" +
10267
			"	private final void foo3(Object... o){}" +
10268
			"}\n",
10269
			"p1/PreDestroy.java",
10270
			"package p1;\n" +
10271
			"public @interface PreDestroy{}",
10272
			"p1/PostConstruct.java",
10273
			"package p1;\n" +
10274
			"public @interface PostConstruct{}"
10275
			};
10276
	String expectedErrorString = 
10277
			"----------\n" + 
10278
			"1. WARNING in p\\A.java (at line 8)\n" + 
10279
			"	@SuppressWarnings(\"null\")\n" + 
10280
			"	                  ^^^^^^\n" + 
10281
			"Unnecessary @SuppressWarnings(\"null\")\n" + 
10282
			"----------\n" + 
10283
			"2. ERROR in p\\A.java (at line 13)\n" + 
10284
			"	@SafeVarargs	private final void foo3(Object... o){}}\n" + 
10285
			"	            	                   ^^^^^^^^^^^^^^^^^\n" + 
10286
			"The method foo3(Object...) from the type A is never used locally\n" + 
10287
			"----------\n";
10288
	runNegativeTest(
10289
			true,
10290
			testFiles,
10291
			null, 
10292
			customOptions,
10293
			expectedErrorString,
10294
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
10295
}
10151
}
10296
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java (-7 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 167-178 Link Here
167
				break;
167
				break;
168
			case TypeIds.T_JavaLangInvokeMethodHandlePolymorphicSignature :
168
			case TypeIds.T_JavaLangInvokeMethodHandlePolymorphicSignature :
169
				tagBits |= TagBits.AnnotationPolymorphicSignature;
169
				tagBits |= TagBits.AnnotationPolymorphicSignature;
170
				break;
171
			case TypeIds.T_JavaxAnnotationPostConstruct :
172
				tagBits |= TagBits.AnnotationPostConstruct;
173
				break;
174
			case TypeIds.T_JavaxAnnotationPreDestroy :
175
				tagBits |= TagBits.AnnotationPreDestroy;
176
				break;
170
				break;
177
			case TypeIds.T_ConfiguredAnnotationNullable :
171
			case TypeIds.T_ConfiguredAnnotationNullable :
178
				tagBits |= TagBits.AnnotationNullable;
172
				tagBits |= TagBits.AnnotationNullable;
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java (-8 lines)
Lines 303-312 Link Here
303
					currentOffset += 2;
303
					currentOffset += 2;
304
					return readTargetValue(currentOffset);
304
					return readTargetValue(currentOffset);
305
				}
305
				}
306
				if (CharOperation.equals(typeName, ConstantPool.JAVAX_ANNOTATION_PREDESTROY)) {
307
					this.standardAnnotationTagBits |= TagBits.AnnotationPreDestroy;
308
					return currentOffset;
309
				}
310
				break;
306
				break;
311
			case 32:
307
			case 32:
312
				if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTION)) {
308
				if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_RETENTION)) {
Lines 315-324 Link Here
315
				}
311
				}
316
				if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_INHERITED)) {
312
				if (CharOperation.equals(typeName, ConstantPool.JAVA_LANG_ANNOTATION_INHERITED)) {
317
					this.standardAnnotationTagBits |= TagBits.AnnotationInherited;
313
					this.standardAnnotationTagBits |= TagBits.AnnotationInherited;
318
					return currentOffset;
319
				}
320
				if (CharOperation.equals(typeName, ConstantPool.JAVAX_ANNOTATION_POSTCONSTRUCT)) {
321
					this.standardAnnotationTagBits |= TagBits.AnnotationPostConstruct;
322
					return currentOffset;
314
					return currentOffset;
323
				}
315
				}
324
				break;
316
				break;
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 248-255 Link Here
248
	public static final char[] JAVA_LANG_SAFEVARARGS = "Ljava/lang/SafeVarargs;".toCharArray(); //$NON-NLS-1$
248
	public static final char[] JAVA_LANG_SAFEVARARGS = "Ljava/lang/SafeVarargs;".toCharArray(); //$NON-NLS-1$
249
	// java 7 java.lang.invoke.MethodHandle.invokeExact(..)/invokeGeneric(..)
249
	// java 7 java.lang.invoke.MethodHandle.invokeExact(..)/invokeGeneric(..)
250
	public static final char[] JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE = "Ljava/lang/invoke/MethodHandle$PolymorphicSignature;".toCharArray(); //$NON-NLS-1$
250
	public static final char[] JAVA_LANG_INVOKE_METHODHANDLE_POLYMORPHICSIGNATURE = "Ljava/lang/invoke/MethodHandle$PolymorphicSignature;".toCharArray(); //$NON-NLS-1$
251
	public static final char[] JAVAX_ANNOTATION_POSTCONSTRUCT = "Ljavax/annotation/PostConstruct;".toCharArray(); //$NON-NLS-1$
252
	public static final char[] JAVAX_ANNOTATION_PREDESTROY = "Ljavax/annotation/PreDestroy;".toCharArray(); //$NON-NLS-1$
253
251
254
	public static final char[] HashCode = "hashCode".toCharArray(); //$NON-NLS-1$
252
	public static final char[] HashCode = "hashCode".toCharArray(); //$NON-NLS-1$
255
	public static final char[] HashCodeSignature = "()I".toCharArray(); //$NON-NLS-1$; 
253
	public static final char[] HashCodeSignature = "()I".toCharArray(); //$NON-NLS-1$; 
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java (-10 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 54-64 Link Here
54
		count++;
54
		count++;
55
	if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0)
55
	if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0)
56
		count++;
56
		count++;
57
	if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0)
57
	if (count == 0) {
58
		count++;
58
		// this is possible if bits were set for null annotations
59
	if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0)
59
		return recordedAnnotations;
60
		count++;
60
	}
61
	// count must be different from 0
62
61
63
	int index = recordedAnnotations.length;
62
	int index = recordedAnnotations.length;
64
	AnnotationBinding[] result = new AnnotationBinding[index + count];
63
	AnnotationBinding[] result = new AnnotationBinding[index + count];
Lines 81-90 Link Here
81
		result[index++] = buildMarkerAnnotationForMemberType(TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE, env);
80
		result[index++] = buildMarkerAnnotationForMemberType(TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE, env);
82
	if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0)
81
	if ((annotationTagBits & TagBits.AnnotationSafeVarargs) != 0)
83
		result[index++] = buildMarkerAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS, env);
82
		result[index++] = buildMarkerAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS, env);
84
	if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0)
85
		result[index++] = buildMarkerAnnotation(TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT, env);
86
	if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0)
87
		result[index++] = buildMarkerAnnotation(TypeConstants.JAVAX_ANNOTATION_PREDESTROY, env);
88
	return result;
83
	return result;
89
}
84
}
90
85
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (-16 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 380-387 Link Here
380
	switch (this.compoundName.length) {
380
	switch (this.compoundName.length) {
381
381
382
		case 3 :
382
		case 3 :
383
			if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0])
383
			if (!CharOperation.equals(TypeConstants.JAVA, this.compoundName[0]))
384
					&& !CharOperation.equals(TypeConstants.JAVAX, this.compoundName[0]))
385
				return;
384
				return;
386
			
385
			
387
			char[] packageName = this.compoundName[1];
386
			char[] packageName = this.compoundName[1];
Lines 389-407 Link Here
389
			char[] typeName = this.compoundName[2];
388
			char[] typeName = this.compoundName[2];
390
			if (typeName.length == 0) return; // just to be safe
389
			if (typeName.length == 0) return; // just to be safe
391
			// remaining types MUST be in java.*.*
390
			// remaining types MUST be in java.*.*
392
			if (CharOperation.equals(TypeConstants.JAVAX, this.compoundName[0])) {
393
				if (CharOperation.equals(TypeConstants.ANNOTATION, this.compoundName[1])) {
394
					switch (typeName[0]) {
395
						case 'P' :
396
							if (CharOperation.equals(typeName, TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT[2]))
397
								this.id = TypeIds.T_JavaxAnnotationPostConstruct;
398
							if (CharOperation.equals(typeName, TypeConstants.JAVAX_ANNOTATION_PREDESTROY[2]))
399
								this.id = TypeIds.T_JavaxAnnotationPreDestroy;
400
							return;
401
					}
402
				}
403
				return;
404
			}
405
			if (!CharOperation.equals(TypeConstants.LANG, this.compoundName[1])) {
391
			if (!CharOperation.equals(TypeConstants.LANG, this.compoundName[1])) {
406
				switch (packageName[0]) {
392
				switch (packageName[0]) {
407
					case 'i' :
393
					case 'i' :
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java (-7 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 129-138 Link Here
129
	long AnnotationSafeVarargs = ASTNode.Bit52L;
129
	long AnnotationSafeVarargs = ASTNode.Bit52L;
130
	/** @since 3.7 - java 7 MethodHandle.invokeExact(..)/invokeGeneric(..)*/
130
	/** @since 3.7 - java 7 MethodHandle.invokeExact(..)/invokeGeneric(..)*/
131
	long AnnotationPolymorphicSignature = ASTNode.Bit53L;
131
	long AnnotationPolymorphicSignature = ASTNode.Bit53L;
132
	/** @since 3.8 */
133
	long AnnotationPreDestroy = ASTNode.Bit54L;
134
	/** @since 3.8 */
135
	long AnnotationPostConstruct = ASTNode.Bit55L;
136
	/** @since 3.8 null annotation for MethodBinding or LocalVariableBinding (argument): */
132
	/** @since 3.8 null annotation for MethodBinding or LocalVariableBinding (argument): */
137
	long AnnotationNullable = ASTNode.Bit56L;
133
	long AnnotationNullable = ASTNode.Bit56L;
138
	/** @since 3.8 null annotation for MethodBinding or LocalVariableBinding (argument): */
134
	/** @since 3.8 null annotation for MethodBinding or LocalVariableBinding (argument): */
Lines 152-159 Link Here
152
				| AnnotationSuppressWarnings
148
				| AnnotationSuppressWarnings
153
				| AnnotationSafeVarargs
149
				| AnnotationSafeVarargs
154
				| AnnotationPolymorphicSignature
150
				| AnnotationPolymorphicSignature
155
				| AnnotationPostConstruct
156
				| AnnotationPreDestroy
157
				| AnnotationNullable
151
				| AnnotationNullable
158
				| AnnotationNonNull
152
				| AnnotationNonNull
159
				| AnnotationNonNullByDefault
153
				| AnnotationNonNullByDefault
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java (-13 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 177-194 Link Here
177
	char[] SYNTHETIC_ACCESS_METHOD_PREFIX =  "access$".toCharArray(); //$NON-NLS-1$
177
	char[] SYNTHETIC_ACCESS_METHOD_PREFIX =  "access$".toCharArray(); //$NON-NLS-1$
178
	char[] SYNTHETIC_ENUM_CONSTANT_INITIALIZATION_METHOD_PREFIX =  " enum constant initialization$".toCharArray(); //$NON-NLS-1$
178
	char[] SYNTHETIC_ENUM_CONSTANT_INITIALIZATION_METHOD_PREFIX =  " enum constant initialization$".toCharArray(); //$NON-NLS-1$
179
	char[] SYNTHETIC_STATIC_FACTORY =  "<factory>".toCharArray(); //$NON-NLS-1$
179
	char[] SYNTHETIC_STATIC_FACTORY =  "<factory>".toCharArray(); //$NON-NLS-1$
180
	char[][] JAVAX_ANNOTATION_POSTCONSTRUCT =
181
			new char[][] {
182
				JAVAX,
183
				ANNOTATION,
184
				"PostConstruct".toCharArray() //$NON-NLS-1$
185
			};
186
	char[][] JAVAX_ANNOTATION_PREDESTROY =
187
			new char[][] {
188
				JAVAX,
189
				ANNOTATION,
190
				"PreDestroy".toCharArray() //$NON-NLS-1$
191
			};
192
180
193
	// synthetic package-info name
181
	// synthetic package-info name
194
	public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$
182
	public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java (-6 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 100-110 Link Here
100
100
101
	// java 7 java.lang.AutoCloseable
101
	// java 7 java.lang.AutoCloseable
102
	final int T_JavaLangAutoCloseable = 62;
102
	final int T_JavaLangAutoCloseable = 62;
103
104
	// new in 3.8
105
	final int T_JavaxAnnotationPostConstruct = 63;
106
107
	final int T_JavaxAnnotationPreDestroy = 64;
108
	
103
	
109
	// new in 3.8 for null annotations:
104
	// new in 3.8 for null annotations:
110
	final int T_ConfiguredAnnotationNullable = 65;
105
	final int T_ConfiguredAnnotationNullable = 65;
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-4 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 7691-7699 Link Here
7691
			&& CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
7691
			&& CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
7692
		return;
7692
		return;
7693
	}
7693
	}
7694
	if ((method.tagBits & (TagBits.AnnotationPostConstruct | TagBits.AnnotationPreDestroy)) != 0) {
7694
	Annotation[] annotations = methodDecl.annotations;
7695
		// PostConstruct and PreDestroy method are ignored
7695
	int annotationsLen = 0;
7696
		return;
7696
	if (annotations != null) {
7697
		annotationsLen = annotations.length;
7698
	}
7699
	for (int i = 0; i < annotationsLen; i++) {
7700
		if (annotations[i].resolvedType != null) {
7701
			switch (annotations[i].resolvedType.id) {
7702
				case TypeIds.T_JavaLangSuppressWarnings:
7703
				case TypeIds.T_JavaLangDeprecated:
7704
				case TypeIds.T_JavaLangSafeVarargs:
7705
				case TypeIds.T_ConfiguredAnnotationNonNull:
7706
				case TypeIds.T_ConfiguredAnnotationNullable:
7707
				case TypeIds.T_ConfiguredAnnotationNonNullByDefault:
7708
					break;
7709
				default:
7710
					// non-standard annotation found, don't warn
7711
					return;
7712
			}
7713
		}
7697
	}
7714
	}
7698
	this.handle(
7715
	this.handle(
7699
			IProblem.UnusedPrivateMethod,
7716
			IProblem.UnusedPrivateMethod,
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java (-7 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 86-97 Link Here
86
	}
86
	}
87
	if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
87
	if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
88
		annotations.add(getAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS));
88
		annotations.add(getAnnotation(TypeConstants.JAVA_LANG_SAFEVARARGS));
89
	}
90
	if ((tagBits & TagBits.AnnotationPostConstruct) != 0) {
91
		annotations.add(getAnnotation(TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT));
92
	}
93
	if ((tagBits & TagBits.AnnotationPreDestroy) != 0) {
94
		annotations.add(getAnnotation(TypeConstants.JAVAX_ANNOTATION_PREDESTROY));
95
	}
89
	}
96
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
90
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
97
	return (IAnnotation[]) annotations.toArray(new IAnnotation[annotations.size()]);
91
	return (IAnnotation[]) annotations.toArray(new IAnnotation[annotations.size()]);
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java (-7 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 107-118 Link Here
107
	}
107
	}
108
	if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
108
	if ((tagBits & TagBits.AnnotationSafeVarargs) != 0) {
109
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_SAFEVARARGS, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
109
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_SAFEVARARGS, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
110
	}
111
	if ((tagBits & TagBits.AnnotationPostConstruct) != 0) {
112
		generateStandardAnnotation(javaElement, TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
113
	}
114
	if ((tagBits & TagBits.AnnotationPreDestroy) != 0) {
115
		generateStandardAnnotation(javaElement, TypeConstants.JAVAX_ANNOTATION_PREDESTROY, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
116
	}
110
	}
117
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
111
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
118
}
112
}
(-)a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java (-9 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 46-51 Link Here
46
		super(document);
46
		super(document);
47
	}
47
	}
48
	private void addBinaryStandardAnnotations(long annotationTagBits) {
48
	private void addBinaryStandardAnnotations(long annotationTagBits) {
49
		if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
50
			return;
51
		}
49
		if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
52
		if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
50
			char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
53
			char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
51
			addAnnotationTypeReference(compoundName[compoundName.length-1]);
54
			addAnnotationTypeReference(compoundName[compoundName.length-1]);
Lines 83-96 Link Here
83
		if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
86
		if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
84
			char[][] compoundName =
87
			char[][] compoundName =
85
					TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
88
					TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
86
			addAnnotationTypeReference(compoundName[compoundName.length-1]);
87
		}
88
		if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) {
89
			char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT;
90
			addAnnotationTypeReference(compoundName[compoundName.length-1]);
91
		}
92
		if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) {
93
			char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_PREDESTROY;
94
			addAnnotationTypeReference(compoundName[compoundName.length-1]);
89
			addAnnotationTypeReference(compoundName[compoundName.length-1]);
95
		}
90
		}
96
	}
91
	}
(-)a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java (-13 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 90-95 Link Here
90
	return true;
90
	return true;
91
}
91
}
92
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {
92
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {
93
	if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
94
		return false;
95
	}
93
	if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
96
	if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0) {
94
		char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
97
		char[][] compoundName = TypeConstants.JAVA_LANG_ANNOTATION_TARGET;
95
		if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern) ||
98
		if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern) ||
Lines 142-159 Link Here
142
	}
145
	}
143
	if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
146
	if ((annotationTagBits & TagBits.AnnotationPolymorphicSignature) != 0) {
144
		char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
147
		char[][] compoundName = TypeConstants.JAVA_LANG_INVOKE_METHODHANDLE_$_POLYMORPHICSIGNATURE;
145
		if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
146
			return true;
147
		}
148
	}
149
	if ((annotationTagBits & TagBits.AnnotationPostConstruct) != 0) {
150
		char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_POSTCONSTRUCT;
151
		if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
152
			return true;
153
		}
154
	}
155
	if ((annotationTagBits & TagBits.AnnotationPreDestroy) != 0) {
156
		char[][] compoundName = TypeConstants.JAVAX_ANNOTATION_PREDESTROY;
157
		if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
148
		if (checkAnnotationTypeReference(CharOperation.concatWith(compoundName, '.'), pattern)) {
158
			return true;
149
			return true;
159
		}
150
		}

Return to bug 365437