This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Missing Code Attribute with module-export


Chris Dean wrote:
Kawa can produce an empty code attribute when using define-simple-class
in the same file as module-export.  This will throw an exception when
the resulting class is loaded:

    Exception in thread "main" java.lang.ClassFormatError: Bar (Code
    attribute is absent in method that is not abstract or native)

Below is a simple example to reproduce the problem.  As a work around
you may comment out the module-export expression, in which case
Bar.class is fine.

The attached patch should fix the problem.


However, we would also like a non-exported class to not be PUBLIC.
This is a little tricky (a simple fix breaks the testsuite).
Perhaps it's enough that the ClassType field isn't public.
--
	--Per Bothner
per at bothner dot com   http://per.bothner.com/

Index: SetExp.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/SetExp.java,v
retrieving revision 1.41
diff -u -r1.41 SetExp.java
--- SetExp.java	12 Nov 2002 19:03:30 -0000	1.41
+++ SetExp.java	1 Apr 2003 20:10:33 -0000
@@ -141,11 +141,12 @@
 
     Object value;
     Declaration decl = binding;
-    if (! decl.isPrivate()
+    Expression declValue = decl.getValue();
+    if (declValue instanceof LambdaExp
 	&& decl.context instanceof ModuleExp
-	&& decl.getValue() instanceof LambdaExp
-	&& ((LambdaExp) decl.getValue()).getName() != null // FIXME
-	&& decl.getValue() == new_value)
+	&& (! decl.isPrivate() || declValue instanceof ClassExp)
+	&& ((LambdaExp) declValue).getName() != null // FIXME
+	&& declValue == new_value)
       {
 	((LambdaExp) new_value).compileSetField(comp);
       }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]