Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336394 - [compiler] ClassFormatError caused by abstract static method
Summary: [compiler] ClassFormatError caused by abstract static method
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 0.8   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 0.8 M6   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-04 15:47 EST by Stephan Herrmann CLA
Modified: 2011-06-07 10:26 EDT (History)
0 users

See Also:


Attachments
test (3.30 KB, patch)
2011-02-04 15:47 EST, Stephan Herrmann CLA
no flags Details | Diff
test & fix (28.62 KB, patch)
2011-02-06 15:04 EST, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2011-02-04 15:47:42 EST
Created attachment 188367 [details]
test

In OT/J it is possible to declare a method as "abstract static", which
is illegal in plain Java. Such a method can be used in two situations:
A) bind by a callout binding in the same role class
B) implement/bind in an implicit sub-role (if the super-role class is abstract)

While A) works fine as demonstrated by
   CalloutMethodBinding.test3113_calloutToStatic1()
B) fails with a ClassFormatError:
  Method getV in class T1$__OT__R has illegal modifiers: 0x409
(test3113_calloutToStatic3 in the attached patch).


Two issues need to be investigated:
- why is T1$__OT__R accessed although T2 is instantated (and thus
  T2$__OT__R) ?
- does one of the conflicting modifiers require to be re-coded using
  a bytecode attribute or should a method body throwing an exception
  be generated?
Comment 1 Stephan Herrmann CLA 2011-02-06 15:04:51 EST
Created attachment 188411 [details]
test & fix

This patch resolves the problem by these steps:

- when generating code for an abstract static role method,
  - remove the abstract flag
  - generate a method body that throws a RuntimeException
- message send from team to static abstract role method uses 
  SyntheticRoleBridgeMethodBinding
  - create synthetic binding from SourceTypeBinding.resolveTypesFor()
  - setup syntheticAccessor in manageSyntheticAccessIfNecessary()
  - explicitly pass synthetic arguments from generateCode()
- improve handling of copyInheritanceSrc
  - already set MethodBinding.copyInheritanceSrc from AstEdit.addMethod()
    which calls resolveTypesFor which needs this field set.
Comment 2 Stephan Herrmann CLA 2011-02-07 02:24:58 EST
Patch has been committed as r1303, r1304.
Apart from an insignificant change in generated SMAPs all tests pass.

In the future we might want to look at the general issue of overriding
static role methods along implicit inheritance (by what time we should
strive to minimize the number of synthetic methods).
Comment 3 Stephan Herrmann CLA 2011-06-07 10:26:28 EDT
Core issue is verified using build 201106070730.

However, see fups bug 348572 and bug 348574.