JRuby 9.1.6.0 tries to access O_TMPFILE under Windows #4332

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

Projects

None yet

5 participants

@ips219
ips219 commented Nov 23, 2016 edited

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
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
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.

@nirvdrum
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).

@dcransac
dcransac commented Dec 4, 2016 edited

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
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
ips219 commented Dec 12, 2016 edited

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
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 headius added a commit that referenced this issue Dec 12, 2016
@headius headius Update jnr.
This commit aligns all jnr projects on latest versions. It should
also fix #4332.
e9807d6
@headius headius referenced this issue Dec 12, 2016
Merged

Update jnr. #4378

@headius headius added a commit that closed this issue Dec 12, 2016
@headius headius Update jnr.
This commit aligns all jnr projects on latest versions. It should
also fix #4332.
cb0b3ea
@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