Menu

#1 Static initializer block disappears

closed-fixed
None
5
2002-08-11
2002-07-25
Anonymous
No

I have a class with a static initialization block, like so:

public class ListCanvas {
static {
// initialization code here
}

public ListCanvas() {}

// methods...
}

After obfuscation, the static initializer is not called when the class is loaded.

Related

Bugs: #701

Discussion

  • Eric Lafortune

    Eric Lafortune - 2002-07-26
    • status: open --> open-works-for-me
     
  • Eric Lafortune

    Eric Lafortune - 2002-07-26

    Logged In: YES
    user_id=555208

    This bug is very surprising. It sounds really serious, but I
    haven't
    seen it before, nor heard anyone complain. My test cases run
    fine.

    Maybe J2ME (mentioned in your e-mail) is different in some
    respect.
    In J2SE, the static <clinit> method is kept because it is
    treated as
    overriding <clinit> in java.lang.Object. Perhaps
    java.lang.Object
    doesn't have a <clinit> method in J2ME? A workaround would
    then be
    to explicitly specify the option
    -keepclassmembers class * { static void <clinit>(); }

    I'll look into it.

     
  • Eric Lafortune

    Eric Lafortune - 2002-08-08

    Logged In: YES
    user_id=555208

    The diagnosis above is correct. So for the time
    being, you can specify

    -keepclassmembers class * { static void <clinit>(); }

    when processing J2ME applications.

    I've fixed it for version 1.2, which is due for release
    in a couple of days.

    Eric.

     
  • Eric Lafortune

    Eric Lafortune - 2002-08-08
    • status: open-works-for-me --> open-accepted
     
  • Eric Lafortune

    Eric Lafortune - 2002-08-08
    • assigned_to: nobody --> lafortune
     
  • Eric Lafortune

    Eric Lafortune - 2002-08-11
    • status: open-accepted --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB