Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324526

Summary: [reconciler] NPE during AST creation, team in role file subclassing non-team role
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTJAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.7   
Target Milestone: 0.7.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
test and fix
none
additional fixes none

Description Stephan Herrmann CLA 2010-09-04 18:47:11 EDT
Given a nested team in a role file that extends a non-team role
the reconciler throws NPE during AST creation like this:

java.lang.NullPointerException
	at org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.BytecodeTransformer.checkCopyNonWideConstants(BytecodeTransformer.java:117)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:972)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:1145)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:424)
	at org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies.establishUnitState(Dependencies.java:357)
	at org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies.ensureState(Dependencies.java:257)
	at org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies.ensureState(Dependencies.java:212)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1233)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:693)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1180)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:806)

This is caused by the TeamMethodGenerator having no valid bytecode of
o.o.Team. The regular compiler, however, does not have this problem.
Comment 1 Stephan Herrmann CLA 2010-09-04 19:31:16 EDT
Created attachment 178218 [details]
test and fix

When the TeamMethodGenerator tries to fetch the class bytes,
they may have already been nulled by ClassFileReader.initialize().
It turns out, however, that some MethodInfos still hold on to the
byte codes (due to our own hack in MethodInfo).

To make the new test pass also some additions to JCLMin are needed,
because we need to resolve the constant pool references of method 
bodies from o.o.Team against this library.
Comment 2 Stephan Herrmann CLA 2010-09-04 19:41:58 EDT
Patch has been committed as r760 - r766 (incl. deploying JCLMin1.5).
Comment 3 Stephan Herrmann CLA 2010-09-07 06:12:55 EDT
Created attachment 178305 [details]
additional fixes

This patch implements more cases for fetching bytecode of o.o.Team:
* when compiling o.o.Team from source collect bytes via different call chains
  using existing mechanim in MethodModel
* when o.o.Team is converted from JavaElement do not try to copy bytecodes,
  we have none.

No new tests, debugged using a rt-workbench with two workspace projects:
org.eclipse.objectteams.runtime (for Team.java) and 
org.eclipse.objectteams.otdt.jdt.ui (for CreateMethodMappingCompletionProposal)
Comment 4 Stephan Herrmann CLA 2010-09-23 17:07:48 EDT
Verified using I201009211735, both by the test in OTReconcilerTests
and by frequently challenging CreateMethodMappingCompletionProposal.