Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 02fb2c93c948
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5461d4bf5d8e
Choose a head ref

Commits on Jan 11, 2016

  1. filter obviously wrong class-names/package-names when finding JavaExt…

    …ension Service.class
    
    fixes #3586
    
    Sponsored by Lookout Inc.
    mkristian committed Jan 11, 2016
    Copy the full SHA
    f2b44a7 View commit details
  2. Copy the full SHA
    04e6eaf View commit details
  3. Fixes #3505. stat.writable? incorrectly reporting false for some dire…

    …ctories on Windows 7
    enebo committed Jan 11, 2016
    Copy the full SHA
    43b86a2 View commit details

Commits on Jan 12, 2016

  1. Upodate to latest jnr-posix. Fixes #3525. stat.writable? incorrectly …

    …reporting false for some directories on Windows 7
    enebo committed Jan 12, 2016
    Copy the full SHA
    ee09c3c View commit details

Commits on Jan 13, 2016

  1. on windows treat expand_path with jar-uris special

    to normalize the path of the jar!/* part of the url uses file system
    operations which brings in windows drive letters which needs to be removed again.
    
    Sponsored by Lookout Inc.
    mkristian committed Jan 13, 2016
    Copy the full SHA
    6b115fa View commit details
  2. Update to jnr-posix 3.0.25. Fixes failover stat FindFirstFile detecti…

    …ng FileNotFound conditions
    enebo committed Jan 13, 2016
    Copy the full SHA
    606b943 View commit details
  3. Copy the full SHA
    c49b529 View commit details
  4. Update to latest jcodings

    enebo committed Jan 13, 2016
    Copy the full SHA
    5b40913 View commit details
  5. Copy the full SHA
    5c425ad View commit details
  6. Fixes #3550. Warning "io/console not supported; tty will not be manip…

    …ulated" occurs again on 1.7.23
    enebo committed Jan 13, 2016
    1
    Copy the full SHA
    eb1dd7a View commit details

Commits on Jan 14, 2016

  1. Revert "Use methods instead of procs for converters."

    This reverts commit 65c5183.
    headius committed Jan 14, 2016
    Copy the full SHA
    4139aa7 View commit details
  2. Copy the full SHA
    f7f5369 View commit details

Commits on Jan 15, 2016

  1. Also use the anonymous wrap class for pushRubyClass, for defs.

    Part of work for 1.7 load(..., true) for #3180.
    headius committed Jan 15, 2016
    Copy the full SHA
    73daf0a View commit details
  2. Copy the full SHA
    2e2647e View commit details
  3. Copy the full SHA
    b93fbb6 View commit details
  4. Copy the full SHA
    2398cec View commit details
  5. Move parser scripts to tool.

    headius committed Jan 15, 2016
    Copy the full SHA
    d3f90ac View commit details
  6. Copy the full SHA
    e179f01 View commit details

Commits on Jan 16, 2016

  1. Don't deoptimize while loops just because of a block arg.

    Fixes #2954.
    
    See discussion for details on this change.
    headius committed Jan 16, 2016
    Copy the full SHA
    c40bfa8 View commit details
  2. Copy the full SHA
    e7e3815 View commit details

Commits on Jan 18, 2016

  1. Copy the full SHA
    b1734a8 View commit details

Commits on Jan 19, 2016

  1. Copy the full SHA
    0942111 View commit details
  2. Copy the full SHA
    eff542b View commit details
  3. Copy the full SHA
    ebba35a View commit details
  4. local (non-member) classes should have correct name just like anonymo…

    …us classes
    
    local and anonymous classes had empty names <= 1.7.19 and the change (for anonymous classes) was not spec-ed properly, but with features such as Java proxy marshalling (#3526) this gained importance.
    kares committed Jan 19, 2016
    Copy the full SHA
    5d277a3 View commit details
  5. Copy the full SHA
    371964d View commit details
  6. Copy the full SHA
    5d5b9f8 View commit details

Commits on Jan 20, 2016

  1. Merge branch 'jruby-1_7'

    * jruby-1_7: (27 commits)
      Update jnr-posix to finally fix 32 bit JVM crasher on windows stat
      pend marshaling behavior - not working for Java non-member classes (GH-3526)
      local (non-member) classes should have correct name just like anonymous classes
      DRY out getClassFromPath usage in UnmarshalStream (all delegating to one method)
      review runtime's getClassFromPath
      hide unmarshalObject methods that use private inner type as a parameter
      Update for newer jnr-posix for windows 32 bit JVM stat workaround
      Remove remaining `should` uses from compiler specs.
      Don't deoptimize while loops just because of a block arg.
      Always assign masgn destructured args in block as block-local.
      Move parser scripts to tool.
      Add case for breakage fixed in b93fbb6e431.
      Check for empty identifiers and treat them as false.
      Same fix for AOT as for interp for #3180.
      Also use the anonymous wrap class for pushRubyClass, for defs.
      More robust, less breaky fix to omit bad class/package elements.
      Revert "Use methods instead of procs for converters."
      Fixes #3550. Warning "io/console not supported; tty will not be manipulated" occurs again on 1.7.23
      updating to jcodings messes with this obscure char no longer being considered a space.
      Update to latest jcodings
      ...
    kares committed Jan 20, 2016
    Copy the full SHA
    b35397b View commit details
  2. Copy the full SHA
    d565996 View commit details
  3. Merge branch 'master' of github.com:jruby/jruby

    * 'master' of github.com:jruby/jruby:
      [Truffle] tag failing Time specs
      Abstract pipe cleanup a bit better.
      Do not use SelectorPool to create selectors that won't pool.
    kares committed Jan 20, 2016
    Copy the full SHA
    5461d4b View commit details
27 changes: 13 additions & 14 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -2838,31 +2838,30 @@ public PrintStream getOutputStream() {
return new PrintStream(new IOOutputStream(getGlobalVariables().get("$stdout")));
}

public RubyModule getClassFromPath(String path) {
RubyModule c = getObject();
public RubyModule getClassFromPath(final String path) {
if (path.length() == 0 || path.charAt(0) == '#') {
throw newTypeError("can't retrieve anonymous class " + path);
}

RubyModule c = getObject();
int pbeg = 0, p = 0;
for(int l=path.length(); p<l; ) {
while(p<l && path.charAt(p) != ':') {
p++;
}
String str = path.substring(pbeg, p);
for ( final int l = path.length(); p < l; ) {
while ( p < l && path.charAt(p) != ':' ) p++;

final String str = path.substring(pbeg, p);

if(p<l && path.charAt(p) == ':') {
if(p+1 < l && path.charAt(p+1) != ':') {
throw newTypeError("undefined class/module " + path.substring(pbeg,p));
if ( p < l && path.charAt(p) == ':' ) {
if ( ++p < l && path.charAt(p) != ':' ) {
throw newTypeError("undefined class/module " + str);
}
p += 2;
pbeg = p;
pbeg = ++p;
}

IRubyObject cc = c.getConstant(str);
if(!(cc instanceof RubyModule)) {
if ( ! ( cc instanceof RubyModule ) ) {
throw newTypeError(path + " does not refer to class/module");
}
c = (RubyModule)cc;
c = (RubyModule) cc;
}
return c;
}
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -1703,6 +1703,12 @@ else if (protocol.find()) {
}
if (postFix.contains("..")) {
postFix = "!" + canonicalizePath(postFix.substring(1));
if (Platform.IS_WINDOWS && postFix.startsWith("!")) {
postFix = postFix.replace("\\", "/");
if (startsWithDriveLetterOnWindows(postFix.substring(1))) {
postFix = "!" + postFix.substring(3);
}
}
}
return runtime.newString(preFix + realPath + postFix);
}
Original file line number Diff line number Diff line change
@@ -56,8 +56,11 @@ public RubyModule initialize(RubyModule proxy) {
proxy.setParent(parent);

// set the Java class name and package
if ( javaClass.isAnonymousClass() ) {
String baseName = ""; // javaClass.getSimpleName() returns "" for anonymous
if ( javaClass.isMemberClass() ) {
proxy.setBaseName( javaClass.getSimpleName() );
}
else { // javaClass.isAnonymousClass() || javaClass.isLocalClass()
String baseName = javaClass.getSimpleName(); // returns "" for anonymous
if ( enclosingClass != null ) {
// instead of an empty name anonymous classes will have a "conforming"
// although not valid (by Ruby semantics) RubyClass name e.g. :
@@ -75,9 +78,6 @@ else if ( length > offset + 1 ) { // skip '$'
}
proxy.setBaseName( baseName );
}
else {
proxy.setBaseName( javaClass.getSimpleName() );
}

installClassFields(proxyClass, state);
installClassInstanceMethods(proxyClass, state);
8 changes: 5 additions & 3 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -1409,11 +1409,13 @@ public static StaticScope preLoad(ThreadContext context, String[] varNames) {
}

public static void preLoadCommon(ThreadContext context, StaticScope staticScope, boolean wrap) {
RubyModule objectClass = context.runtime.getObject();
if (wrap) {
staticScope.setModule(RubyModule.newModule(context.runtime));
} else {
staticScope.setModule(context.runtime.getObject());
objectClass = RubyModule.newModule(context.runtime);
}

staticScope.setModule(objectClass);

DynamicScope scope = DynamicScope.newDynamicScope(staticScope);

// Each root node has a top-level scope that we need to push
105 changes: 44 additions & 61 deletions core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
* Copyright (C) 2004 Charles O Nutter <headius@headius.com>
* Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
* Copyright (C) 2006 Ola Bini <ola.bini@ki.se>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -105,29 +105,29 @@ public IRubyObject unmarshalObject(boolean callProc) throws IOException {
// introduced for keeping ivar read state recursively.
private static class MarshalState {
private boolean ivarWaiting;

MarshalState(boolean ivarWaiting) {
this.ivarWaiting = ivarWaiting;
}

boolean isIvarWaiting() {
return ivarWaiting;
}

void setIvarWaiting(boolean ivarWaiting) {
this.ivarWaiting = ivarWaiting;
}
}

// r_object0
public IRubyObject unmarshalObject(MarshalState state) throws IOException {
private IRubyObject unmarshalObject(MarshalState state) throws IOException {
return unmarshalObject(state, true);
}

// r_object0
public IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws IOException {
int type = readUnsignedByte();
IRubyObject result = null;
private IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws IOException {
final int type = readUnsignedByte();
final IRubyObject result;
if (cache.isLinkType(type)) {
result = cache.readLink(this, type);
if (callProc) return doCallProcForLink(result, type);
@@ -147,15 +147,29 @@ public void registerLinkTarget(IRubyObject newObject) {
}

public static RubyModule getModuleFromPath(Ruby runtime, String path) {
RubyModule value = runtime.getClassFromPath(path);
if (!value.isModule()) throw runtime.newArgumentError(path + " does not refer module");
final RubyModule value = getConstantFromPath(runtime, path);
if ( ! value.isModule() ) throw runtime.newArgumentError(path + " does not refer module");
return value;
}

public static RubyClass getClassFromPath(Ruby runtime, String path) {
RubyModule value = runtime.getClassFromPath(path);
if (!value.isClass()) throw runtime.newArgumentError(path + " does not refer class");
return (RubyClass)value;
final RubyModule value = getConstantFromPath(runtime, path);
if ( ! value.isClass() ) throw runtime.newArgumentError(path + " does not refer class");
return (RubyClass) value;
}

private static RubyModule getConstantFromPath(Ruby runtime, String path) {
final RubyModule value;
try {
value = runtime.getClassFromPath(path);
}
catch (RaiseException e) {
if ( runtime.getModule("NameError").isInstance(e.getException()) ) {
throw runtime.newArgumentError("undefined class/module " + path);
}
throw e;
}
return value;
}

private IRubyObject doCallProcForLink(IRubyObject result, int type) {
@@ -226,20 +240,12 @@ private IRubyObject unmarshalObjectDirectly(int type, MarshalState state, boolea
break;
case 'e':
RubySymbol moduleName = (RubySymbol) unmarshalObject();
RubyModule tp = null;
try {
tp = runtime.getClassFromPath(moduleName.asJavaString());
} catch (RaiseException e) {
if (runtime.getModule("NameError").isInstance(e.getException())) {
throw runtime.newArgumentError("undefined class/module " + moduleName.asJavaString());
}
throw e;
}
final RubyModule tp = getModuleFromPath(runtime, moduleName.asJavaString());

rubyObj = unmarshalObject();

tp.extend_object(rubyObj);
tp.callMethod(runtime.getCurrentContext(),"extended", rubyObj);
tp.callMethod(runtime.getCurrentContext(), "extended", rubyObj);
break;
case 'l' :
rubyObj = RubyBignum.unmarshalFrom(this);
@@ -266,7 +272,7 @@ private IRubyObject unmarshalObjectDirectly(int type, MarshalState state, boolea
if (callProc) {
return doCallProcForObj(rubyObj);
}

return rubyObj;
}

@@ -337,18 +343,7 @@ public int unmarshalInt() throws IOException {
private IRubyObject defaultObjectUnmarshal() throws IOException {
RubySymbol className = (RubySymbol) unmarshalObject(false);

RubyClass type = null;
try {
type = getClassFromPath(runtime, className.toString());
} catch (RaiseException e) {
if (runtime.getModule("NameError").isInstance(e.getException())) {
throw runtime.newArgumentError("undefined class/module " + className.asJavaString());
}

throw e;
}

assert type != null : "type shouldn't be null.";
RubyClass type = getClassFromPath(runtime, className.toString());

IRubyObject result = (IRubyObject)type.unmarshal(this);

@@ -359,27 +354,27 @@ public void defaultVariablesUnmarshal(IRubyObject object) throws IOException {
int count = unmarshalInt();

RubyClass cls = object.getMetaClass().getRealClass();

for (int i = 0; i < count; i++) {

IRubyObject key = unmarshalObject(false);

if (runtime.is1_9() && object instanceof EncodingCapable) {

EncodingCapable strObj = (EncodingCapable)object;

if (key.asJavaString().equals(MarshalStream.SYMBOL_ENCODING_SPECIAL)) {

// special case for USASCII and UTF8
if (unmarshalObject().isTrue()) {
strObj.setEncoding(UTF8Encoding.INSTANCE);
} else {
strObj.setEncoding(USASCIIEncoding.INSTANCE);
}
continue;

} else if (key.asJavaString().equals("encoding")) {

IRubyObject encodingNameObj = unmarshalObject(false);
String encodingNameStr = encodingNameObj.asJavaString();
ByteList encodingName = new ByteList(ByteList.plain(encodingNameStr));
@@ -391,10 +386,10 @@ public void defaultVariablesUnmarshal(IRubyObject object) throws IOException {
Encoding encoding = entry.getEncoding();
strObj.setEncoding(encoding);
continue;

} // else fall through as normal ivar
}

String name = key.asJavaString();
IRubyObject value = unmarshalObject();

@@ -405,7 +400,7 @@ public void defaultVariablesUnmarshal(IRubyObject object) throws IOException {
private IRubyObject uclassUnmarshall() throws IOException {
RubySymbol className = (RubySymbol)unmarshalObject(false);

RubyClass type = (RubyClass)runtime.getClassFromPath(className.asJavaString());
RubyClass type = getClassFromPath(runtime, className.asJavaString());

// singleton, raise error
if (type.isSingleton()) throw runtime.newTypeError("singleton can't be loaded");
@@ -431,7 +426,7 @@ private IRubyObject userUnmarshal(MarshalState state) throws IOException {
String className = unmarshalObject(false).asJavaString();
ByteList marshaled = unmarshalString();
RubyClass classInstance = findClass(className);
RubyString data = RubyString.newString(getRuntime(), marshaled);
RubyString data = RubyString.newString(runtime, marshaled);
if (state.isIvarWaiting()) {
defaultVariablesUnmarshal(data);
state.setIvarWaiting(false);
@@ -451,19 +446,7 @@ private IRubyObject userNewUnmarshal() throws IOException {
}

private RubyClass findClass(String className) {
RubyModule classInstance;
try {
classInstance = runtime.getClassFromPath(className);
} catch (RaiseException e) {
if (runtime.getModule("NameError").isInstance(e.getException())) {
throw runtime.newArgumentError("undefined class/module " + className);
}
throw e;
}
if (! (classInstance instanceof RubyClass)) {
throw runtime.newArgumentError(className + " does not refer class"); // sic
}
return (RubyClass) classInstance;
return getClassFromPath(runtime, className);
}

public int read() throws IOException {
2 changes: 2 additions & 0 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -394,6 +394,8 @@ def self.bar
# non-local flow control with while loops
run("a = 0; 1.times { a += 1; redo if a < 2 }; a") {|result| expect(result).to eq 2 }
run("def foo(&b); while true; b.call; end; end; foo { break 3 }") {|result| expect(result).to eq 3 }

expect(lambda { run("def foo(&b); while true; b.call; end; end; foo { eval 'break 3' }") }).to raise_error(LocalJumpError)
end

it "compiles block passing" do
2 changes: 1 addition & 1 deletion spec/compiler/rubyscript_spec.rb
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
script1.add_import('my.java.import')

script2 = JRuby::Compiler::RubyScript.new("script2")
expect(script2.imports).not_to include('my.java.import')
expect(script2.imports).to_not include('my.java.import')
end

end
12 changes: 12 additions & 0 deletions spec/compiler/skinnymethodadapter_spec.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,18 @@
end
end.map(&:to_s).map(&:downcase)
# 1.9 makes them symbols, so to_s the lot
insn_opcodes = insn_opcodes.map(&:to_s)
instance_methods = SkinnyMethodAdapter.instance_methods.map(&:to_s)

insn_opcodes.each do |opcode|
opcode = opcode.downcase
expect(instance_methods).to include(opcode)
end

expect(instance_methods).to include("go_to")
expect(instance_methods).to include("voidreturn")
expect(instance_methods).to include("instance_of")
expect(instance_methods).to include("newobj")
end

it "supports all JVM opcodes" do
30 changes: 30 additions & 0 deletions spec/java_integration/classes/name_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require File.dirname(__FILE__) + "/../spec_helper"

describe "Java class" do

java_import "java_integration.fixtures.InnerClasses"

it "has (qualified) Ruby name" do
expect( InnerClasses.name ).to eql 'Java::Java_integrationFixtures::InnerClasses'
end

it "has name for inner classes" do
base_name = InnerClasses.name
expect( InnerClasses::CapsInnerClass.name ).to eql "#{base_name}::CapsInnerClass"
expect( InnerClasses::lowerInnerClass.name ).to eql "#{base_name}::lowerInnerClass"
end

it "has name for local classes" do
base_name = InnerClasses.name
local = InnerClasses.localMethodClass
# java_integration.fixtures.InnerClasses$1CapsImpl
expect( local.class.name ).to eql "#{base_name}::1CapsImpl"
end

it "has name for anonymous classes" do
base_name = InnerClasses.name
anon = InnerClasses.anonymousMethodClass
expect( anon.class.name ).to eql "#{base_name}::1"
end

end
Loading