Mercury Bugs - mercury
View Issue Details
0000245mercuryBugpublic2011-12-07 22:192011-12-13 03:23
Assigned Tojuliensf 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000245: [Java, 11.07-beta-2011-12-06] crashes with ClassCastException
DescriptionA program as simple as,

main(!IO) :- io.write_string("Hello, world!\n", !IO).

which runs fine in --grade=asm_fast.gc , or with 11.01's Java,
crashes on start with 11.07-beta-2011-12-06's java grade.

Exception in thread "main" java.lang.ExceptionInInitializerError
    at jmercury.list.MR_init_scalars_0(
    at jmercury.list.<clinit>(
    at jmercury.hello.main_2_p_0(
    at jmercury.hello.main(
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to jmercury.runtime.PseudoTypeInfo
    at jmercury.runtime.TypeInfo_Struct.init(
    at jmercury.runtime.TypeInfo_Struct.<init>(
    at jmercury.pretty_printer.MR_init_scalars_0(
    at jmercury.pretty_printer.<clinit>(
    ... 5 more
Additional InformationMercury Compiler, version 11.07-beta-2011-12-06, configured for i686-pc-linux-gnu

java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.4) (fedora-
OpenJDK Server VM (build 20.0-b11, mixed mode)

# failed identically with:
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Server VM (build 21.1-b02, mixed mode)

# 11.07-beta-2011-12-06 was built with
configured by ./configure, generated by GNU Autoconf 2.61,
  with options \"'--disable-most-grades' '--enable-libgrades=java' '--with-default-grade=java'\"
TagsNo tags attached.
Attached Files? bug245.m (507) 2011-12-12 02:59

2011-12-07 23:11   
We appear to be calling the old constructor for the TypeInfo_Struct class (i.e. the one with
the arity argument) from the initializer for some scalar common data.
2011-12-12 03:03   
(Last edited: 2011-12-12 05:09)
I've updated a reduced test case. The problem occurs because we generate the following:

MR_scalar_common_1[1] = new jmercury.runtime.TypeInfo_Struct(jmercury.runtime.TypeInfo_Struct.maybe_new(builtin.builtin__type_ctor_info_func_0),

The TypeInfo_Struct no longer takes an arity argument. There seems to be an issue with how
rtti_to_mlds.m handles pseudo type-infos -- I've fixed that in my workspace and it makes no
difference to this. (For the Java backend, psuedo type-infos reuse the TypeInfo_Struct class.)

Does something other than rtti_to_mlds.m generate calls to the TypeInfo_Struct constructor?

2011-12-12 17:21   
The answer to the above is yes, ml_unify_gen.m also generates them (when processing unifications
that involve type_info_cell_constructors). I will post a fix for this shortly.
2011-12-13 03:23   
Fix committed.

Issue History
2011-12-07 22:19jfondrenNew Issue
2011-12-07 22:36juliensfStatusnew => confirmed
2011-12-07 23:11juliensfNote Added: 0000434
2011-12-12 02:59juliensfFile Added: bug245.m
2011-12-12 03:03juliensfNote Added: 0000439
2011-12-12 05:09juliensfNote Edited: 0000439
2011-12-12 17:21juliensfNote Added: 0000440
2011-12-12 17:29juliensfStatusconfirmed => assigned
2011-12-12 17:29juliensfAssigned To => juliensf
2011-12-13 03:23juliensfNote Added: 0000441
2011-12-13 03:23juliensfStatusassigned => resolved
2011-12-13 03:23juliensfResolutionopen => fixed