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

JRuby 9.1.6.0 tries to access O_TMPFILE under Windows #4332

Closed
ips219 opened this Issue Nov 23, 2016 · 7 comments

Comments

Projects
None yet
5 participants
@ips219

ips219 commented Nov 23, 2016

Hi, i've this problem running JRuby 9.1.6.0 on Windows 10 with Java 8

java.lang.NoSuchFieldError: O_TMPFILE
	at org.jruby.RubyFile.createFileClass(RubyFile.java:202)
	at org.jruby.Ruby.initCore(Ruby.java:1570)
	at org.jruby.Ruby.bootstrap(Ruby.java:1352)
	at org.jruby.Ruby.init(Ruby.java:1247)
	at org.jruby.Ruby.newInstance(Ruby.java:339)
	at org.jruby.embed.internal.AbstractLocalContextProvider.getGlobalRuntime(AbstractLocalContextProvider.java:82)
	at org.jruby.embed.internal.SingletonLocalContextProvider.getRuntime(SingletonLocalContextProvider.java:99)
	at org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.runParser(EmbedRubyRuntimeAdapterImpl.java:167)
	at org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.parse(EmbedRubyRuntimeAdapterImpl.java:94)
	at org.jruby.embed.ScriptingContainer.parse(ScriptingContainer.java:1239)
	at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:89)
	at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:133)

I think this is the same problem as related #3332

These are the flags included for linux platform on the jnr.constants.Constant package

package jnr.constants.platform.linux;
import jnr.constants.Constant;
public enum OpenFlags implements Constant {
    O_RDONLY, O_WRONLY, O_RDWR, O_ACCMODE, O_NONBLOCK, O_APPEND, O_SYNC, O_ASYNC, O_FSYNC, O_CREAT, O_TRUNC, O_EXCL, O_TMPFILE, O_CLOEXEC

And these are the flags included for windows platform on the jnr.constants.Constant package

package jnr.constants.platform.windows;
import jnr.constants.Constant;
public enum OpenFlags implements Constant {
    O_APPEND, O_ACCMODE, O_CREAT, O_WRONLY, O_EXCL, O_RDONLY, O_BINARY, O_RDWR, O_TRUNC

As you can see code is checking for this flags and they are not available under windows platform:
https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyFile.java#L202
https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyFile.java#L148

@enebo enebo added this to the JRuby 9.1.7.0 milestone Nov 23, 2016

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Nov 23, 2016

Member

@nirvdrum @eregon you guys recently changed something in jnr-constants right? Or maybe I should ask does any ideas jump out at you? The code in RubyFile looks ok.

Member

enebo commented Nov 23, 2016

@nirvdrum @eregon you guys recently changed something in jnr-constants right? Or maybe I should ask does any ideas jump out at you? The code in RubyFile looks ok.

@nirvdrum

This comment has been minimized.

Show comment
Hide comment
@nirvdrum

nirvdrum Nov 23, 2016

Contributor

The jnr-constants changes were made after the JRuby 9.1.6.0 release. I don't think they're to blame. But I'll investigate a bit.

Contributor

nirvdrum commented Nov 23, 2016

The jnr-constants changes were made after the JRuby 9.1.6.0 release. I don't think they're to blame. But I'll investigate a bit.

@nirvdrum

This comment has been minimized.

Show comment
Hide comment
@nirvdrum

nirvdrum Nov 23, 2016

Contributor

I can't reproduce. But it would be interesting to try with the jnr.constants.fake system property set to false (available in jnr-constants 0.9.7-SNAPSHOT).

Contributor

nirvdrum commented Nov 23, 2016

I can't reproduce. But it would be interesting to try with the jnr.constants.fake system property set to false (available in jnr-constants 0.9.7-SNAPSHOT).

@doriancransac

This comment has been minimized.

Show comment
Hide comment
@doriancransac

doriancransac Dec 4, 2016

Hi I'm currently facing this same problem (using Windows 10, JRE 1.8.0_73 and jruby 9.1.6.0)

Exception in thread "main" java.lang.NoSuchFieldError: O_TMPFILE
	at org.jruby.RubyFile.createFileClass(RubyFile.java:202)
	at org.jruby.Ruby.initCore(Ruby.java:1570)
	at org.jruby.Ruby.bootstrap(Ruby.java:1352)
	at org.jruby.Ruby.init(Ruby.java:1247)
	at org.jruby.Ruby.newInstance(Ruby.java:339)
	at org.jruby.embed.internal.AbstractLocalContextProvider.getGlobalRuntime(AbstractLocalContextProvider.java:82)
	at org.jruby.embed.internal.SingletonLocalContextProvider.getRuntime(SingletonLocalContextProvider.java:99)
	at org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.runParser(EmbedRubyRuntimeAdapterImpl.java:167)
	at org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.parse(EmbedRubyRuntimeAdapterImpl.java:94)
	at org.jruby.embed.ScriptingContainer.parse(ScriptingContainer.java:1239)
	at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:89)
	at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:142)
	at TestEngine.speedTest(TestEngine.java:39)
	at TestEngine.main(TestEngine.java:14)

Is there any way I could help investigating this?

I forgot to mention I set the system property "jnr.constants.fake" to false. Here's my test program :

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleBindings;

public class TestEngine {

	public static void main(String...strings){

		for(String s : new String[] {"jython", "scala", "rhino", "nashorn", "jruby"})
		{
			for(int i = 0; i <3; i++)
				speedTest(s);
		}		
	}
	
	public static void speedTest(String engineKey){
		long s1 = System.currentTimeMillis();
		ScriptEngine engine = new ScriptEngineManager().getEngineByName(engineKey);

		if(engine == null){
			System.out.println(engineKey + " engine not found.");
			return;
		}
		
		String script = "java.lang.System.out.println(\""+engineKey+"\")";
		if(engineKey.equals("jython"))
			script = "from java.lang import System as javasystem\njavasystem.out.println(\""+engineKey+"\")";
		else{
			script = "java.lang.System.out.println(\""+engineKey+"\")";
		}
		
		Bindings b = new SimpleBindings();
		//b.put("n", 10);
		
		long end1 = System.currentTimeMillis();
		
		try {
			long s2 = System.currentTimeMillis();
			//engine.eval("1 to n.asInstanceOf[Int] foreach java.lang.System.out.println", b);
			engine.eval(script);
			long end2 = System.currentTimeMillis();
			System.out.println("chargement:" + (end1 - s1) + ", execution:" + (end2-s2));
		} catch (ScriptException e) {
			e.printStackTrace();
		}
	}

}

doriancransac commented Dec 4, 2016

Hi I'm currently facing this same problem (using Windows 10, JRE 1.8.0_73 and jruby 9.1.6.0)

Exception in thread "main" java.lang.NoSuchFieldError: O_TMPFILE
	at org.jruby.RubyFile.createFileClass(RubyFile.java:202)
	at org.jruby.Ruby.initCore(Ruby.java:1570)
	at org.jruby.Ruby.bootstrap(Ruby.java:1352)
	at org.jruby.Ruby.init(Ruby.java:1247)
	at org.jruby.Ruby.newInstance(Ruby.java:339)
	at org.jruby.embed.internal.AbstractLocalContextProvider.getGlobalRuntime(AbstractLocalContextProvider.java:82)
	at org.jruby.embed.internal.SingletonLocalContextProvider.getRuntime(SingletonLocalContextProvider.java:99)
	at org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.runParser(EmbedRubyRuntimeAdapterImpl.java:167)
	at org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.parse(EmbedRubyRuntimeAdapterImpl.java:94)
	at org.jruby.embed.ScriptingContainer.parse(ScriptingContainer.java:1239)
	at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:89)
	at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:142)
	at TestEngine.speedTest(TestEngine.java:39)
	at TestEngine.main(TestEngine.java:14)

Is there any way I could help investigating this?

I forgot to mention I set the system property "jnr.constants.fake" to false. Here's my test program :

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleBindings;

public class TestEngine {

	public static void main(String...strings){

		for(String s : new String[] {"jython", "scala", "rhino", "nashorn", "jruby"})
		{
			for(int i = 0; i <3; i++)
				speedTest(s);
		}		
	}
	
	public static void speedTest(String engineKey){
		long s1 = System.currentTimeMillis();
		ScriptEngine engine = new ScriptEngineManager().getEngineByName(engineKey);

		if(engine == null){
			System.out.println(engineKey + " engine not found.");
			return;
		}
		
		String script = "java.lang.System.out.println(\""+engineKey+"\")";
		if(engineKey.equals("jython"))
			script = "from java.lang import System as javasystem\njavasystem.out.println(\""+engineKey+"\")";
		else{
			script = "java.lang.System.out.println(\""+engineKey+"\")";
		}
		
		Bindings b = new SimpleBindings();
		//b.put("n", 10);
		
		long end1 = System.currentTimeMillis();
		
		try {
			long s2 = System.currentTimeMillis();
			//engine.eval("1 to n.asInstanceOf[Int] foreach java.lang.System.out.println", b);
			engine.eval(script);
			long end2 = System.currentTimeMillis();
			System.out.println("chargement:" + (end1 - s1) + ", execution:" + (end2-s2));
		} catch (ScriptException e) {
			e.printStackTrace();
		}
	}

}

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Dec 9, 2016

Member

@dcransac @ips219 I also cannot reproduce this but I am on Win7 and Java 1.8.0_111. At this point I feel like the two most likely candidates would be:

  1. It involves platform detection. Like something in Win10 is confusing our platform detection? @nirvdrum did you test with win10? The other thought is running from mingw or something (although I tested that as well as CMD on win7).

  2. It involves Java somehow. I find this unlikely but just noticed I am running a new JVM.

Member

enebo commented Dec 9, 2016

@dcransac @ips219 I also cannot reproduce this but I am on Win7 and Java 1.8.0_111. At this point I feel like the two most likely candidates would be:

  1. It involves platform detection. Like something in Win10 is confusing our platform detection? @nirvdrum did you test with win10? The other thought is running from mingw or something (although I tested that as well as CMD on win7).

  2. It involves Java somehow. I find this unlikely but just noticed I am running a new JVM.

@ips219

This comment has been minimized.

Show comment
Hide comment
@ips219

ips219 Dec 12, 2016

Maybe there are some dependency problems on jruby-core package related with the jnr-constants package?

I've tried to force jnr-constants with the required version (0.9.5) and it works:

        <dependency>
            <groupId>com.github.jnr</groupId>
            <artifactId>jnr-constants</artifactId>
            <version>0.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-core</artifactId>
            <version>9.1.6.0</version>
            <exclusions> 
                <exclusion>
                    <groupId>com.github.jnr</groupId>
                    <artifactId>jnr-constants</artifactId>
                </exclusion>
            </exclusions> 
        </dependency>

Note that on jruby-core 9.1.6.0, jnr-constants dependency is declared on the POM with 0.9.5 version but when I build my project version 0.9.4 is downloaded as some of the dependencies of jruby-core require that version (jnr-unixsocket & jnr-enxio)

ips219 commented Dec 12, 2016

Maybe there are some dependency problems on jruby-core package related with the jnr-constants package?

I've tried to force jnr-constants with the required version (0.9.5) and it works:

        <dependency>
            <groupId>com.github.jnr</groupId>
            <artifactId>jnr-constants</artifactId>
            <version>0.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-core</artifactId>
            <version>9.1.6.0</version>
            <exclusions> 
                <exclusion>
                    <groupId>com.github.jnr</groupId>
                    <artifactId>jnr-constants</artifactId>
                </exclusion>
            </exclusions> 
        </dependency>

Note that on jruby-core 9.1.6.0, jnr-constants dependency is declared on the POM with 0.9.5 version but when I build my project version 0.9.4 is downloaded as some of the dependencies of jruby-core require that version (jnr-unixsocket & jnr-enxio)

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Dec 12, 2016

Member

@ips219 Yes I think that's the only likely explanation. This error should not be possible if JRuby builds properly. However if it then proceeds to capture the wrong version of jnr-constants, this error could result.

I will do a pass over all jnr projects and ensure they are updated to latest versions of everything.

Member

headius commented Dec 12, 2016

@ips219 Yes I think that's the only likely explanation. This error should not be possible if JRuby builds properly. However if it then proceeds to capture the wrong version of jnr-constants, this error could result.

I will do a pass over all jnr projects and ensure they are updated to latest versions of everything.

headius added a commit that referenced this issue Dec 12, 2016

Update jnr.
This commit aligns all jnr projects on latest versions. It should
also fix #4332.

@headius headius referenced this issue Dec 12, 2016

Merged

Update jnr. #4378

@headius headius closed this in cb0b3ea Dec 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment