This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: compilation error
- From: Per Bothner <per at bothner dot com>
- To: walter at pelissero dot org
- Cc: kawa at sources dot redhat dot com
- Date: Wed, 07 Aug 2002 21:06:09 -0700
- Subject: Re: compilation error
- References: <15697.47456.213731.133127@hyde.lpds.sublink.org>
Walter C. Pelissero wrote:
With Kawa 1.6.99 I tried to compile this line
(make <java.awt.Dimension> width: 2 height: 3)
But I got
java.lang.Error: gnu.bytecode.Field does not implement Externalizable
Thanks for the report. The appended patch should fix it.
I've checked this in, as well as a testcase.
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/
Index: SlotSet.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/kawa/reflect/SlotSet.java,v
retrieving revision 1.10
diff -u -r1.10 SlotSet.java
--- SlotSet.java 25 Jul 2002 17:43:27 -0000 1.10
+++ SlotSet.java 8 Aug 2002 03:52:42 -0000
@@ -210,31 +210,46 @@
Expression value = args[2];
Type type = isStatic ? kawa.standard.Scheme.exp2Type(arg0)
: arg0.getType();
- String name = ClassMethods.checkName(arg1);
- if (type instanceof ClassType && name != null)
+ Object part = null;
+ if (type instanceof ClassType)
{
ClassType ctype = (ClassType) type;
- Object part = getField(ctype, name);
- if (part != null)
- {
- boolean isStaticField =
- (part instanceof gnu.bytecode.Field)
- ? ((gnu.bytecode.Field) part).getStaticFlag()
- : ((gnu.bytecode.Method) part).getStaticFlag();
- args[0].compile(comp,
- isStaticField ? Target.Ignore
- : Target.pushValue(ctype));
+ String name = ClassMethods.checkName(arg1);
+ if (name != null)
+ {
+ part = getField(ctype, name);
+ if (part == null && type != Type.pointer_type)
+ comp.error('e', "no slot `"+name+"' in "+ctype.getName());
+ }
+ else if (arg1 instanceof QuoteExp)
+ {
+ part = ((QuoteExp) arg1).getValue();
+ // Inlining (make <type> field: value) creates calls to
+ // setFieldReturnObject whose 2nd arg is a Field or Method.
+ if (! (part instanceof Field || part instanceof Method))
+ {
+ part = null;
+ }
+ }
+
+ if (part != null)
+ {
+ boolean isStaticField =
+ (part instanceof gnu.bytecode.Field)
+ ? ((gnu.bytecode.Field) part).getStaticFlag()
+ : ((gnu.bytecode.Method) part).getStaticFlag();
+ args[0].compile(comp,
+ isStaticField ? Target.Ignore
+ : Target.pushValue(ctype));
if (returnSelf)
comp.getCode().emitDup(ctype);
- compileSet(this, ctype, args[2], part, comp);
+ compileSet(this, ctype, args[2], part, comp);
if (returnSelf)
target.compileFromStack(comp, ctype);
else
comp.compileConstant(Values.empty, target);
- return;
- }
- if (type != Type.pointer_type)
- comp.error('e', "no slot `"+name+"' in "+ctype.getName());
+ return;
+ }
}
ApplyExp.compile(exp, comp, target);
}