Skip to content

Commit

Permalink
Merge branch 'jruby-1_7'
Browse files Browse the repository at this point in the history
* jruby-1_7: (25 commits)
  adding a test to reproduce another (NPE) BiVariableMap bug - but all seems well
  review JRuby's ScriptEngineManager + ServiceFinder helper internals
  only wrap raise exceptions (from ruby) + cleanup not thrown checked exceptions
  add a test to verify we're not pre-initializing runtime when asked for instance config
  make ScriptingContainer's fields final
  assert correct ARGV behavior with javax.script embed engine
  make sure ARGV is internally set as an Argv instance (as intended) not a Constant !
  fix Map clear bug when ARGV's value is kept incorrectly + print var values on toString
  extract checking whether variable sharing is enabled into a helper + fields can go final
  Constant's initialized field is never read
  dry out ClassVariable some
  implement a toString method for the BiVariableMap and some more test code
  add an updateVariable helper + do more cleanup - some comment on impl weirdness
  revisit BiVariableMap internals to avoid NPEs in 'advanced' usage + align as Map impl
  [embed] cleanup predefined global variable name checking
  cleanup (internal) guts for variable impls - use a VALID_NAME final field pattern
  final name field and cleanup method internals + add a bunch of package level helpers
  better safe than sorry - synchronize LocalContext's field getters
  unused imports
  re-use LocalContext's fields instead of introducing static ones in singleton provider impl
  ...

Conflicts:
	core/src/main/java/org/jruby/RubyDir.java
	core/src/main/java/org/jruby/RubyFile.java
	core/src/main/java/org/jruby/RubyFileStat.java
	core/src/main/java/org/jruby/RubyIO.java
	core/src/main/java/org/jruby/RubyKernel.java
	core/src/main/java/org/jruby/RubyString.java
	core/src/main/java/org/jruby/embed/ScriptingContainer.java
	core/src/main/java/org/jruby/embed/internal/AbstractLocalContextProvider.java
	core/src/main/java/org/jruby/embed/internal/ConcurrentLocalContextProvider.java
	core/src/main/java/org/jruby/embed/internal/EmbedEvalUnitImpl.java
	core/src/main/java/org/jruby/embed/internal/ThreadSafeLocalContextProvider.java
	core/src/main/java/org/jruby/embed/variable/Argv.java
	core/src/main/java/org/jruby/embed/variable/Constant.java
	core/src/main/java/org/jruby/util/StringSupport.java
	core/src/test/java/org/jruby/embed/internal/ConcurrentLocalContextProviderTest.java
	core/src/test/java/org/jruby/embed/jsr223/JRubyEngineTest.java
	test/externals/ruby1.9/excludes/TestFile.rb
  • Loading branch information
kares committed Apr 14, 2015
2 parents abed82b + 6a454ef commit acfe1af
Show file tree
Hide file tree
Showing 29 changed files with 1,454 additions and 1,090 deletions.
136 changes: 68 additions & 68 deletions core/src/main/java/org/jruby/embed/ScriptingContainer.java

Large diffs are not rendered by default.

Expand Up @@ -29,6 +29,7 @@
*/
package org.jruby.embed.internal;

import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.embed.LocalVariableBehavior;

Expand All @@ -37,19 +38,62 @@
* @author Yoko Harada <yokolet@gmail.com>
*/
public abstract class AbstractLocalContextProvider implements LocalContextProvider {
protected RubyInstanceConfig config = new RubyInstanceConfig();
protected LocalVariableBehavior behavior = LocalVariableBehavior.TRANSIENT;

protected final RubyInstanceConfig config;
protected final LocalVariableBehavior behavior;
protected boolean lazy = true;

public RubyInstanceConfig getRubyInstanceConfig() {
return config;
protected AbstractLocalContextProvider() {
this( new RubyInstanceConfig() );
}

protected AbstractLocalContextProvider(RubyInstanceConfig config) {
this.config = config; this.behavior = LocalVariableBehavior.TRANSIENT;
}

protected AbstractLocalContextProvider(RubyInstanceConfig config, LocalVariableBehavior behavior) {
this.config = config; this.behavior = behavior;
}

protected AbstractLocalContextProvider(LocalVariableBehavior behavior) {
this.config = new RubyInstanceConfig(); this.behavior = behavior;
}

protected LocalContext getInstance() {
return new LocalContext(config, behavior, lazy);
}


@Override
public RubyInstanceConfig getRubyInstanceConfig() {
return config;
}

@Override
public LocalVariableBehavior getLocalVariableBehavior() {
return behavior;
}

boolean isGlobalRuntimeReady() { return Ruby.isGlobalRuntimeReady(); }

Ruby getGlobalRuntime(AbstractLocalContextProvider provider) {
if ( isGlobalRuntimeReady() ) {
return Ruby.getGlobalRuntime();
}
return Ruby.newInstance(provider.config);
}

RubyInstanceConfig getGlobalRuntimeConfig(AbstractLocalContextProvider provider) {
// make sure we do not yet initialize the runtime here
if ( isGlobalRuntimeReady() ) {
return getGlobalRuntime(provider).getInstanceConfig();
}
return provider.config;
}

static RubyInstanceConfig getGlobalRuntimeConfigOrNew() {
return Ruby.isGlobalRuntimeReady() ?
Ruby.getGlobalRuntime().getInstanceConfig() :
new RubyInstanceConfig();
}

}

0 comments on commit acfe1af

Please sign in to comment.