Bug 333825 - CompletionEngine had unused variables treated differently by new compiler
Summary: CompletionEngine had unused variables treated differently by new compiler
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Nitin Dahyabhai CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 333678
  Show dependency tree
 
Reported: 2011-01-09 23:54 EST by David Williams CLA
Modified: 2011-04-05 02:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Williams CLA 2011-01-09 23:54:08 EST
related to bug 333678 ... 

The class has many unused variables, it seems. There are (as far as I can see from decompiling the byte codes) 3 of them that are now correctly detected by new JDT compiler, and removed from byte codes. Hence making the bits different, even though version and qualifier are the same. 

The three are

relevence in  public void acceptPackage(char[] packageName);

staticsOnly in   private void findFieldsAndMethodsFromMissingFieldType(char[] token, org.eclipse.wst.jsdt.internal.compiler.lookup.Scope scope, org.eclipse.wst.jsdt.internal.compiler.lookup.InvocationSite invocationSite, boolean insideTypeAnnotation);

staticsOnly in   private void findFieldsAndMethodsFromMissingReturnType(char[] token, org.eclipse.wst.jsdt.internal.compiler.lookup.TypeBinding[] arguments, org.eclipse.wst.jsdt.internal.compiler.lookup.Scope scope, org.eclipse.wst.jsdt.internal.compiler.lookup.InvocationSite invocationSite, boolean insideTypeAnnotation);

If it is desired to leave this bundle the same in maintenance stream and head, then the variables would have to be fixed/removed from source. 

The reason there were not (correctly) detected as unused before is that they are involved, at some point, in some computation ... and those computations might have side effects ... so can not just blindly remove every line they are used. For example, in acceptPackage, we have 

int relevance = computeBaseRelevance();
relevance += computeRelevanceForResolution();
relevance += computeRelevanceForInterestingProposal();

which blindly could only be reduced to 

computeRelevanceForResolution();
computeRelevanceForInterestingProposal();

So ... not sure what to advise ... ideally you could clean up the code?  [Tip: eclipse37M4 will correctly show the variables unused ... previous versions won't]

If you really wanted, I could fix our releng test to ignore this difference in byte codes produced by the compiler ... but seems like a bad idea long term, since then might miss more important errors/changes in the future ... as well as risk having different bits "in the wild" that have same version/qualifier.
Comment 1 Nitin Dahyabhai CLA 2011-04-05 02:29:49 EDT
Updated and rereleased.