Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchFieldError on last just released jdk #35

Closed
He-Pin opened this issue Feb 5, 2013 · 16 comments
Closed

NoSuchFieldError on last just released jdk #35

He-Pin opened this issue Feb 5, 2013 · 16 comments

Comments

@He-Pin
Copy link

He-Pin commented Feb 5, 2013

Caused by: java.lang.RuntimeException: init
at com.barchart.udt.SocketUDT.(SocketUDT.java:153)
... 3 more
Caused by: java.lang.NoSuchFieldError: port
at com.barchart.udt.SocketUDT.initClass0(Native Method)
at com.barchart.udt.SocketUDT.(SocketUDT.java:150)
... 3 more

hi ,barchart ,cause the oracle change the class InetSocketAddress's implement in the last release,so your native binding which get the filed id such as addr and port of the InetSocketAddress class will cause an error,not the change is moving the addr and port field to an inner class:

public class InetSocketAddress
    extends SocketAddress
{
    // Private implementation class pointed to by all public methods.
    private static class InetSocketAddressHolder {
        // The hostname of the Socket Address
        private String hostname;
        // The IP address of the Socket Address
        private InetAddress addr;
        // The port number of the Socket Address
        private int port;

        private InetSocketAddressHolder(String hostname, InetAddress addr, int port) {
            this.hostname = hostname;
            this.addr = addr;
            this.port = port;
        }
.....

    public InetSocketAddress(InetAddress addr, int port) {
        holder = new InetSocketAddressHolder(
                        null,
                        addr == null ? InetAddress.anyLocalAddress() : addr,
                        checkPort(port));
    }

.....

    private final transient InetSocketAddressHolder holder;

this change may be cause you guys to rewrite the native binding ...

@carrot-garden
Copy link
Contributor

can you please report result of

java -version

@He-Pin
Copy link
Author

He-Pin commented Feb 5, 2013

The version of jdk 6
kerr@DearPanda:/usr/lib/jvm/java-6-oracle/bin$ ./java -version

java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)

The version of jdk 7
kerr@DearPanda:/usr/lib/jvm/java-7-oracle/bin$ ./java -version

java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

@carrot-garden
Copy link
Contributor

  1. is this the same change needed for android?
  2. can you make the change and send pull request?

@He-Pin
Copy link
Author

He-Pin commented Feb 5, 2013

@carrot-garden
1 )This change only affect the oracle-java 6 and 7 last update and i am not that clear about the openJDK ,i think this may be the cause of the security issue just talk around on the web,the android don't need this adapt cause the android use the android style java API implement.

  1. I noticed that you added the android support in your github projecct ,did you planing to support android now? When i porting your greate job to android platform,i counted the only issue is that [Issue ARM support for Android #18 ] ,and as you see ,i don't how how to change the native address convert to an android java's InetSocketAddress's instanse,this will cause the native crash when i call getSocketAddress,blablabla.

  2. Could you guys write and roadmap on your wiki?So i will know what are you guys planning for.

  3. i will trying to make this change ,should i check your source code from the maven repo but not the github?

@wmichal
Copy link

wmichal commented Feb 5, 2013

Hello,

I've also encountered this problem in the little project that I take part in. It is 100% reproducible on Oracle's JRE 7u13 and 6u39.

[Thread-6] ERROR com.barchart.udt.SocketUDT - Failed to INIT native library
java.lang.NoSuchFieldError: port
at com.barchart.udt.SocketUDT.initClass0(Native Method)
at com.barchart.udt.SocketUDT.(SocketUDT.java:150)
at others.ReceiveFiles.setTransmisson(ReceiveFiles.java:273)
at others.ReceiveFiles.run(ReceiveFiles.java:365)

It is probably caused by fixing the http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-0433 vulnerability. The root cause was that method UDT_InitFieldRefAll access field 'port' in Java class InetSocketAddress (around line 400) that is private. Previous JREs allowed this, but in the newest one is the bug was fixed and thus the method doesn't work anymore. The fix would be to access the field value using public getter, and rewrite every function that sets this field's value that the new InetSocketAddress would be spawned with correct 'port' value (because there is no public setter for this field, it's accesible only through constructor).

@He-Pin
Copy link
Author

He-Pin commented Feb 6, 2013

@wmichal, yes you are right~!
the cause is the change just made by oracel in the InetSocketAddress implement.
Then should change the native implement of barchart-udt

@He-Pin
Copy link
Author

He-Pin commented Feb 6, 2013

@carrot-garden thanks,i will test it later.

@carrot-garden
Copy link
Contributor

@CCob
Copy link
Collaborator

CCob commented Feb 6, 2013

I can confirm this works with the latest JRE 7. Any chance you can cut a release (again, sorry).

@He-Pin
Copy link
Author

He-Pin commented Feb 6, 2013

@carrot-garden ,i confirm it works on the last oracle JDK 7 too,did it affect the older jre?

@He-Pin
Copy link
Author

He-Pin commented Feb 6, 2013

@CCob ,hi CCob,do you want to implement the android support?!

@CCob
Copy link
Collaborator

CCob commented Feb 6, 2013

No I don't, do you :)

@carrot-garden
Copy link
Contributor

@He-Pin
Copy link
Author

He-Pin commented Feb 6, 2013

@CCob ,i wanna to ,but i am going to my spring festival,when i go back hometwon ,i have no network connection...

@He-Pin
Copy link
Author

He-Pin commented Feb 17, 2013

@carrot-garden should the next version add support the older version of JDK or OpenJDK which not change the implement?

@carrot-garden
Copy link
Contributor

this fix works fine both in old and new jdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants