Fix a problem that prevents Java 1.7 from compiling the Java code generated by

Branches: main, 11.07

Fix a problem that prevents Java 1.7 from compiling the Java code generated by
the Mercury compiler.  Previously, the TypeInfo_Struct class in the Java
version of Mercury's runtime defined the following constructors:

    public TypeInfo_Struct(TypeInfoStruct ti, int arity, Object... as)
    public TypeInfo_Struct(TypeInfoStruct ti, Object... as)

Changes to the way most specific varargs method selection works in Java 1.7
means the above is now rejected by the Java compiler.  (It should apparently
have never been allowed in the first place.)

The fix is to delete the first constructor above from the runtime and not
generate code that provides the arity.  (The arity argument was only ever used
as a sanity check on the number of the following arguments.)

java/runtime/TypeInfo_Struct.java
	Delete one of the ambiguous constructors from this class.

compiler/rtti_to_mlds.m:
	Don't pass an arity argument to the constructor for TypeInfo_Struct
	objects.
This commit is contained in:
Julien Fischer
2011-11-30 15:38:57 +00:00
parent 913b6bab86
commit 8225fdbe76
2 changed files with 32 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
//
// Copyright (C) 2001-2004 The University of Melbourne.
// Copyright (C) 2001-2004, 2011 The University of Melbourne.
// This file may only be copied under the terms of the GNU Library General
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
@@ -87,12 +87,16 @@ public class TypeInfo_Struct extends PseudoTypeInfo
}
// XXX untested guess
public TypeInfo_Struct(TypeInfo_Struct ti, int arity, Object... as)
{
init(ti.type_ctor, arity, as);
}
// XXX untested guess
// We don't have a version of this constructor that also takes the arity
// as an argument (as we do with the init method above), e.g.
//
// public TypeInfo_Struct(TypeInfo_Struct ti, int artiy, Object... as)
//
// because such overloadings are not allowed under Java 1.7. (Previous
// versions of Java incorrectly allowed them.)
// If you change this you will also need to update the code in
// compiler/rtti_to_mlds.m.
//
public TypeInfo_Struct(TypeInfo_Struct ti, Object... as)
{
init(ti.type_ctor, as);