You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Benjamin Reed (JIRA)" <ji...@apache.org> on 2006/07/18 00:14:13 UTC

[jira] Created: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

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

        

[jira] Reopened: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-367?page=all ]

Doug Cutting reopened HADOOP-367:
---------------------------------

             
Oops.  Mistakenly resolved.

> 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
>             Fix For: 0.5.0
>
>         Attachments: f.patch
>
>
> 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

        

[jira] Updated: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Hairong Kuang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-367?page=all ]

Hairong Kuang updated HADOOP-367:
---------------------------------

    Attachment: reflection.patch

This patch provides a util function newInstance. It's an incomplete patch to this bug. Still need to clean up all the factories.

> 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
>             Fix For: 0.5.0
>
>         Attachments: f.patch, reflection.patch
>
>
> 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

        

[jira] Updated: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-367?page=all ]

Benjamin Reed updated HADOOP-367:
---------------------------------

    Attachment: f.patch

Arg! It seems that public static methods on non-public classes cannot be called with reflection :( So I took a different approach that is simpler and less code. (This patch removes 132 lines and adds 18.)

I noticed that all of the factories simply created new objects. So now the WritableFactories.newInstance method finds the factory that corresponds to the package of the class and lets that factory create it. This means that there needs to be a WriteableFactory for each package that has Writables. This lowers the number of overall factories while adding one visible factory per package. It also simplifies the Writables since they don't need to worry about factories anymore.

> 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
>         Attachments: f.patch
>
>
> 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

        

[jira] Resolved: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-367?page=all ]

Doug Cutting resolved HADOOP-367.
---------------------------------

    Fix Version/s: 0.5.0
       Resolution: Fixed

I just committed this, with one change.  Your patch mistakenly removed the 'in' field.

Thanks, Ben!

> 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
>             Fix For: 0.5.0
>
>         Attachments: f.patch
>
>
> 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

        

[jira] Commented: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-367?page=comments#action_12424652 ] 
            
Doug Cutting commented on HADOOP-367:
-------------------------------------

We might as well just use setAccessible.  Let's just add a static util method:

public Object newInstance(Class aClass);

This can can be implemented like JobConf.newInstance().  Then JobConf.newInstance() can call this, and we can replace all calls to WritableFactories.newInstance() with calls to this.  If we ever become worried about abuse of this method, we can restrict its use to particular, approved packages or somesuch.

This would be even less code!

> 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
>             Fix For: 0.5.0
>
>         Attachments: f.patch
>
>
> 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

        

[jira] Commented: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-367?page=comments#action_12442183 ] 
            
Benjamin Reed commented on HADOOP-367:
--------------------------------------


   [[ Old comment, sent by email on Tue, 25 Jul 2006 10:30:37 -0700 ]]

When would you call setAccessable? It would have to be outside of the class 
since nothing is initialized.

One option would be to put a public static getFactory() method on the class. 
Not only would that cause the static blocks to be run, but it would allow you 
to get rid of the factory table and just use reflection to call getFactory() 
on the class if there is one otherwise fall back to newInstance().

ben



> 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
>         Attachments: f.patch, reflection.patch
>
>
> 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

        

[jira] Commented: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-367?page=comments#action_12425331 ] 
            
Doug Cutting commented on HADOOP-367:
-------------------------------------

I committed the reflection patch, but am not yet closing this.

Hairong, will you provide a patch replacing WritableFactory with ReflectionUtils?

> 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
>             Fix For: 0.5.0
>
>         Attachments: f.patch, reflection.patch
>
>
> 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

        

[jira] Commented: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-367?page=comments#action_12423469 ] 
            
Benjamin Reed commented on HADOOP-367:
--------------------------------------

When would you call setAccessable? It would have to be outside of the class 
since nothing is initialized at class load time.

One option would be to put a public static getFactory() method on class that want this non-public behavior. 
Not only would that cause the static blocks to be run when called, but it would allow you 
to get rid of the factory table and just use reflection to call getFactory() 
on the class if there is one otherwise fall back to newInstance().

> 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

        

[jira] Resolved: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Owen O'Malley (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-367?page=all ]

Owen O'Malley resolved HADOOP-367.
----------------------------------

    Resolution: Duplicate

This has been fixed across several patches by using the new ReflectionUtils.newInstance in all contexts. We currently require java 5.0, so clearly this bug isn't present anymore.

> 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
>         Attachments: f.patch, reflection.patch
>
>
> 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

        

[jira] Commented: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-367?page=comments#action_12423573 ] 
            
Doug Cutting commented on HADOOP-367:
-------------------------------------

I was thinking of a hack where we call setAccessible on the constructor before calling it, as is done in JobConf.  We'd bypass the factory altogether.

Your proposal (a public static getFactory method) is better.  Would you like to prepare a patch?

> 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

        

[jira] Updated: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HADOOP-367?page=all ]

Doug Cutting updated HADOOP-367:
--------------------------------

    Comment: was deleted

> 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
>             Fix For: 0.5.0
>
>         Attachments: f.patch
>
>
> 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

        

[jira] Commented: (HADOOP-367) Static blocks do not automatically run when a class is loaded in Java 5.0

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HADOOP-367?page=comments#action_12423251 ] 
            
Doug Cutting commented on HADOOP-367:
-------------------------------------

Will the setAccessable trick used in JobConf.newInstance() work here too?  I hope it is possible to have non-public classes as parameters in non-public RPC protocols.  For implementation flexibility we'd like to keep some protocols package-protected, so that our only back-compatibility burdens are public, client APIs.

> 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