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

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-1 / +17 lines)
Lines 299-311 Link Here
299
			methodBindings[1] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUEOF); // add <EnumType> valueOf()
299
			methodBindings[1] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUEOF); // add <EnumType> valueOf()
300
		}
300
		}
301
		// create bindings for source methods
301
		// create bindings for source methods
302
		boolean hasNativeMethods = false;
302
		if (sourceType.isAbstract()) {
303
		if (sourceType.isAbstract()) {
303
			for (int i = 0; i < size; i++) {
304
			for (int i = 0; i < size; i++) {
304
				if (i != clinitIndex) {
305
				if (i != clinitIndex) {
305
					MethodScope scope = new MethodScope(this, methods[i], false);
306
					MethodScope scope = new MethodScope(this, methods[i], false);
306
					MethodBinding methodBinding = scope.createMethod(methods[i]);
307
					MethodBinding methodBinding = scope.createMethod(methods[i]);
307
					if (methodBinding != null) // is null if binding could not be created
308
					if (methodBinding != null) { // is null if binding could not be created
308
						methodBindings[count++] = methodBinding;
309
						methodBindings[count++] = methodBinding;
310
						hasNativeMethods = hasNativeMethods || methodBinding.isNative();
311
					}
309
				}
312
				}
310
			}
313
			}
311
		} else {
314
		} else {
Lines 317-322 Link Here
317
					if (methodBinding != null) { // is null if binding could not be created
320
					if (methodBinding != null) { // is null if binding could not be created
318
						methodBindings[count++] = methodBinding;
321
						methodBindings[count++] = methodBinding;
319
						hasAbstractMethods = hasAbstractMethods || methodBinding.isAbstract();
322
						hasAbstractMethods = hasAbstractMethods || methodBinding.isAbstract();
323
						hasNativeMethods = hasNativeMethods || methodBinding.isNative();
320
					}
324
					}
321
				}
325
				}
322
			}
326
			}
Lines 327-332 Link Here
327
			System.arraycopy(methodBindings, 0, methodBindings = new MethodBinding[count], 0, count);
331
			System.arraycopy(methodBindings, 0, methodBindings = new MethodBinding[count], 0, count);
328
		sourceType.tagBits &= ~(TagBits.AreMethodsSorted|TagBits.AreMethodsComplete); // in case some static imports reached already into this type
332
		sourceType.tagBits &= ~(TagBits.AreMethodsSorted|TagBits.AreMethodsComplete); // in case some static imports reached already into this type
329
		sourceType.setMethods(methodBindings);
333
		sourceType.setMethods(methodBindings);
334
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=243917, conservatively tag all methods and fields as
335
		// being in use if there is a native method in the class.
336
		if (hasNativeMethods) {
337
			MethodBinding[] methods2 = sourceType.methods();
338
			for (int i = 0; i < methods2.length; i++) {
339
				methods2[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
340
			}
341
			FieldBinding[] fields = sourceType.fields();
342
			for (int i = 0; i < fields.length; i++) {
343
				fields[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed;	
344
			}
345
		}
330
	}
346
	}
331
347
332
	SourceTypeBinding buildType(SourceTypeBinding enclosingType, PackageBinding packageBinding, AccessRestriction accessRestriction) {
348
	SourceTypeBinding buildType(SourceTypeBinding enclosingType, PackageBinding packageBinding, AccessRestriction accessRestriction) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java (+20 lines)
Lines 5286-5289 Link Here
5286
		false,
5286
		false,
5287
		null);
5287
		null);
5288
}
5288
}
5289
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=243917
5290
public void test105() {
5291
	this.runNegativeTest(
5292
		new String[] {
5293
			"X.java",
5294
			"public class X {\n" +
5295
			"    static {\n" +
5296
			"        System.loadLibrary(\"tpbrooktrout\");\n" +
5297
			"    }\n" +
5298
			"    private final int time;\n" +
5299
			"    private int foo() { return 0;}\n" +
5300
			"    private class Inner {}\n" +
5301
			"    public X(int delay) {\n" +
5302
			"        time = delay;\n" +
5303
			"    }\n" +
5304
			"    public native void run(Inner i);\n" +
5305
			"}\n"
5306
		},
5307
		"");
5308
}
5289
}
5309
}

Return to bug 243917