### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v retrieving revision 1.172 diff -u -r1.172 ClassScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 16 Jun 2009 17:40:44 -0000 1.172 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 8 Jan 2010 11:46:13 -0000 @@ -299,13 +299,16 @@ methodBindings[1] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUEOF); // add valueOf() } // create bindings for source methods + boolean hasNativeMethods = false; if (sourceType.isAbstract()) { for (int i = 0; i < size; i++) { if (i != clinitIndex) { MethodScope scope = new MethodScope(this, methods[i], false); MethodBinding methodBinding = scope.createMethod(methods[i]); - if (methodBinding != null) // is null if binding could not be created + if (methodBinding != null) { // is null if binding could not be created methodBindings[count++] = methodBinding; + hasNativeMethods = hasNativeMethods || methodBinding.isNative(); + } } } } else { @@ -317,6 +320,7 @@ if (methodBinding != null) { // is null if binding could not be created methodBindings[count++] = methodBinding; hasAbstractMethods = hasAbstractMethods || methodBinding.isAbstract(); + hasNativeMethods = hasNativeMethods || methodBinding.isNative(); } } } @@ -327,6 +331,18 @@ System.arraycopy(methodBindings, 0, methodBindings = new MethodBinding[count], 0, count); sourceType.tagBits &= ~(TagBits.AreMethodsSorted|TagBits.AreMethodsComplete); // in case some static imports reached already into this type sourceType.setMethods(methodBindings); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=243917, conservatively tag all methods and fields as + // being in use if there is a native method in the class. + if (hasNativeMethods) { + MethodBinding[] methods2 = sourceType.methods(); + for (int i = 0; i < methods2.length; i++) { + methods2[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed; + } + FieldBinding[] fields = sourceType.fields(); + for (int i = 0; i < fields.length; i++) { + fields[i].modifiers |= ExtraCompilerModifiers.AccLocallyUsed; + } + } } SourceTypeBinding buildType(SourceTypeBinding enclosingType, PackageBinding packageBinding, AccessRestriction accessRestriction) { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java,v retrieving revision 1.24 diff -u -r1.24 ProblemTypeAndMethodTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 7 Jan 2010 20:17:45 -0000 1.24 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java 8 Jan 2010 11:46:34 -0000 @@ -5286,4 +5286,24 @@ false, null); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=243917 +public void test105() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " static {\n" + + " System.loadLibrary(\"tpbrooktrout\");\n" + + " }\n" + + " private final int time;\n" + + " private int foo() { return 0;}\n" + + " private class Inner {}\n" + + " public X(int delay) {\n" + + " time = delay;\n" + + " }\n" + + " public native void run(Inner i);\n" + + "}\n" + }, + ""); +} }