ObjectDB ObjectDB

Issue #1506: Post-compile enhancement sometimes causes error in generic loops: incompatible types found: java.lang.Object: required: Entity

Type: Bug ReoprtVersion: 2.4.0Priority: NormalStatus: ActiveReplies: 2
#1

I have moved from automatic run-time enhancement to explicit post-compile enhancement in an Ant build.xml in a NetBeans web app, and sometimes on editing a file that performs a generic for loop over an @entity type I get a generics error. The generic for loop is: 

for (Steel s: this.steelMaterials.getL_Steel().getEls()) {
 ..
}

Where getEls() here gives:

List<Steel>

This sometimes (only, I don't understand the circumstances) gives this error:

incompatible types
found: java.lang.Object
required: com.example.entity.Steel
        for (Steel s: this.steelMaterials.getL_Steel().getEls()) {

The workaround is to simply clean and build the entire project, which is quite tedious and time-consuming.

I appreciate any feedback on how to address this to improve my development cycle, which is compromised by this.

edit
delete
#2

This rewrite of the generic for loop works but it is inconvenient to have to remove generic loops just because of enhancement:

for (Object os : steelMaterials.getL_Steel().getEls()) {
 if (os instanceof Steel) {
  Steel s = (Steel)os;
  // do something with "cast" Steel (no pun intended)
 }
}
edit
delete
#3

Could you please provide a simple console test case that demonstrates this issue?

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.