Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 155588 Details for
Bug 243917
[compiler] should not warn about unused field when native method present
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 3.85 KB, created by
Srikanth Sankaran
on 2010-01-08 06:44:29 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-01-08 06:44:29 EST
Size:
3.85 KB
patch
obsolete
>### 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 <EnumType> 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" >+ }, >+ ""); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 243917
: 155588