hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Reed (JIRA)" <j...@apache.org>
Subject [jira] Created: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0
Date Mon, 17 Jul 2006 22:14:13 GMT
Static blocks do not automatically run when a class is loaded in Java 5.0

                 Key: HADOOP-367
                 URL: http://issues.apache.org/jira/browse/HADOOP-367
             Project: Hadoop
          Issue Type: Bug
          Components: dfs
    Affects Versions: 0.4.0
         Environment: Java 5.0
            Reporter: Benjamin Reed

There seems to be a change that happened between 1.4 and 1.5 with respect to static initializers.
I can't find this documented, but I can reproduce with a very simple program. Basically, a
static initializer is not called unless a static member/method of the class is accessed or
an instance is created. This is actually what the JLS says, but until 1.5 the static initializers
ran when the class was loaded. Note that this behavior only occurs when running with the 1.5
JRE AND compiling for 1.5.

For many Writables this isn't an issue, so the fallback behavior of the WritableFactory works,
but Block is package private, so loadEdits fails when called from org.apache.hadoop.io.ArrayWritable.readFields()
yielding the following trace:

Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: Class org.apache.hadoop.io.WritableFactories
can not access a member of class org.apache.hadoop.dfs.Block with modifiers "public"
        at org.apache.hadoop.io.WritableFactories.newInstance(WritableFactories.java:49)
        at org.apache.hadoop.io.ArrayWritable.readFields(ArrayWritable.java:81)
        at org.apache.hadoop.dfs.FSDirectory.loadFSEdits(FSDirectory.java:532)
        at org.apache.hadoop.dfs.FSDirectory.loadFSImage(FSDirectory.java:470)
        at org.apache.hadoop.dfs.FSDirectory.<init>(FSDirectory.java:307)
        at org.apache.hadoop.dfs.FSNamesystem.<init>(FSNamesystem.java:177)
        at org.apache.hadoop.dfs.NameNode.<init>(NameNode.java:91)
        at org.apache.hadoop.dfs.NameNode.<init>(NameNode.java:84)
        at org.apache.hadoop.dfs.NameNode.main(NameNode.java:491)

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message