4

Ok, this is probably a longshot but here goes.

In Java (JRE 1.6.0_26-b03) I have two classes, SuperControl and its subclass SubControl. They both need to be persistent objects and I'm using Hibernate Annotations to achieve this. I have approximately 210 classes that are being persisted correctly. Except one isn't.

My problem is that SubControl refuses to inherit in any way besides SINGLE_TABLE. When I say "refuses", I mean that the entire JRE crashes.

This is a bit problematic because I'd really prefer SuperControl to be a mapped superclass of SubControl. SuperControl can also be a persistent entity in its own right. The strange thing is that I have an exactly parallel hierarchy in my code elsewhere that works correctly.

This is what I want:

@Entity
@MappedSuperclass
public class SuperControl extends ItsSuperClass {
  // ...
}

@Entity
public class SubControl extends SuperControl {
  // ...
}

but it bombs out with the error

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (c1_Optimizer.cpp:271), pid=5456, tid=1260
#  guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Client VM (20.1-b02 mixed mode, sharing windows-x86 )
# An error report file with more information is saved as:
# C:\eclipse\hs_err_pid5456.log

Without supplying any inheritance hint, Hibernate defaults to SINGLE_TABLE (which I can tell thanks to the creation of a DTYPE column). I can explicitly specify this without the JVM crashing.

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class SuperControl extends ItsSuperClass {
  // ...
}

@Entity
public class SubControl extends SuperControl {
  // ...
}

The worst part is that if I remove the SubControl class ENTIRELY, or even just its mapping in the hibernate.cfg.xml file, the JVM still crashes. This leads me to believe that there's some kind of hidden linkage between SuperControl and SubControl. Maybe something cached in Eclipse or the like. I've restarted Eclipse, done several clean-and-builds, and even restarted my machine, and the problem's still there.

Any ideas? I've been working on this for hours and have gotten nowhere.

Thanks!

James Cronen
  • 5,715
  • 2
  • 32
  • 52
  • No misconception on your part should ever cause a JVM crash. There must be a bug in the JVM. Have you tried it on another machine, OS and/or JVM? – JB Nizet Jul 01 '11 at 21:38
  • @JB: Not yet. Unfortunately I'm stuck with this architecture so whatever the culprit is I'll have to find a workaround. – James Cronen Jul 03 '11 at 03:11

2 Answers2

6

This looks like a bug 7042153, aka 2210012 reported in early May.

Note the workaround offered by one user: using the "-server" JVM option fixed it for them.

Ed Staub
  • 15,480
  • 3
  • 61
  • 91
  • Also note the Evaluation: "_The problem occurs when we try to fold an If that has arguments of a condition that are constants of an object type and are not loaded._" This suggests another possible workaround: force pre-loading of the problem class, if you can figure out what it is. – Ed Staub Jul 01 '11 at 22:29
  • Thanks Ed, I tried running with `-server` but to no avail. Fortunately there aren't too many classes that could be the culprit, so maybe preloading will do the trick. – James Cronen Jul 03 '11 at 03:08
  • Don't forget all the classes that Hibernate creates on the fly at startup. – Ed Staub Jul 03 '11 at 04:41
3

Try Java 1.6.0_20, and check if that works. You have found a JVM bug, and going back 6 minor versions might be enought to get this running.

You are lucky in the way that this bug is reproducable, so create a minimal testcase and post it to the Oracle bug database.

Daniel
  • 27,718
  • 20
  • 89
  • 133
  • Thanks. I went back a few versions (six, at your urging) and it runs just fine. In the morning I'll verify that nothing too important showed up between _21 and _26. And yes, I'll add this to the bug report once I get past my deadline. – James Cronen Jul 03 '11 at 03:29