Skip to content

Commit f2ff425

Browse files
committed
Merge remote-tracking branch 'origin/jruby-10.0'
2 parents e63fa60 + e433d66 commit f2ff425

12 files changed

Lines changed: 76 additions & 56 deletions

File tree

core/pom.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545

4646
# exclude jnr-ffi to avoid problems with shading and relocation of the asm packages
4747
jar 'com.github.jnr:jnr-netdb:1.2.0', exclusions: ['com.github.jnr:jnr-ffi']
48-
jar 'com.github.jnr:jnr-enxio:0.32.19', exclusions: ['com.github.jnr:jnr-ffi']
49-
jar 'com.github.jnr:jnr-unixsocket:0.38.24', exclusions: ['com.github.jnr:jnr-ffi']
50-
jar 'com.github.jnr:jnr-posix:3.1.21', exclusions: ['com.github.jnr:jnr-ffi']
48+
jar 'com.github.jnr:jnr-enxio:0.32.20', exclusions: ['com.github.jnr:jnr-ffi']
49+
jar 'com.github.jnr:jnr-unixsocket:0.38.25', exclusions: ['com.github.jnr:jnr-ffi']
50+
jar 'com.github.jnr:jnr-posix:3.1.22', exclusions: ['com.github.jnr:jnr-ffi']
5151
jar 'com.github.jnr:jnr-constants:0.10.4', exclusions: ['com.github.jnr:jnr-ffi']
52-
jar 'com.github.jnr:jnr-ffi:2.2.18'
52+
jar 'com.github.jnr:jnr-ffi:2.2.19'
5353
jar 'com.github.jnr:jffi:${jffi.version}'
5454
jar 'com.github.jnr:jffi:${jffi.version}:native'
5555

core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ DO NOT MODIFY - GENERATED CODE
8989
<dependency>
9090
<groupId>com.github.jnr</groupId>
9191
<artifactId>jnr-enxio</artifactId>
92-
<version>0.32.19</version>
92+
<version>0.32.20</version>
9393
<exclusions>
9494
<exclusion>
9595
<groupId>com.github.jnr</groupId>
@@ -100,7 +100,7 @@ DO NOT MODIFY - GENERATED CODE
100100
<dependency>
101101
<groupId>com.github.jnr</groupId>
102102
<artifactId>jnr-unixsocket</artifactId>
103-
<version>0.38.24</version>
103+
<version>0.38.25</version>
104104
<exclusions>
105105
<exclusion>
106106
<groupId>com.github.jnr</groupId>
@@ -111,7 +111,7 @@ DO NOT MODIFY - GENERATED CODE
111111
<dependency>
112112
<groupId>com.github.jnr</groupId>
113113
<artifactId>jnr-posix</artifactId>
114-
<version>3.1.21</version>
114+
<version>3.1.22</version>
115115
<exclusions>
116116
<exclusion>
117117
<groupId>com.github.jnr</groupId>
@@ -133,7 +133,7 @@ DO NOT MODIFY - GENERATED CODE
133133
<dependency>
134134
<groupId>com.github.jnr</groupId>
135135
<artifactId>jnr-ffi</artifactId>
136-
<version>2.2.18</version>
136+
<version>2.2.19</version>
137137
</dependency>
138138
<dependency>
139139
<groupId>com.github.jnr</groupId>

core/src/main/java/org/jruby/RubyEncoding.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,11 @@ public static Encoding areCompatible(IRubyObject obj1, IRubyObject obj2) {
157157
if (!(obj1 instanceof RubyString) && enc1 instanceof USASCIIEncoding) return enc2;
158158

159159
if (!(obj1 instanceof RubyString)) {
160-
IRubyObject objTmp = obj1; // swap1 obj1 & obj2
160+
IRubyObject objTmp = obj1; // swap obj1 & obj2
161161
obj1 = obj2;
162162
obj2 = objTmp;
163-
164-
Encoding encTmp = enc1; // swap their encodings
165-
enc1 = enc2;
166-
enc2 = encTmp;
163+
// Note: enc1/enc2 are NOT swapped — they retain the
164+
// original argument order, matching CRuby's rb_enc_compatible.
167165
}
168166

169167
if (obj1 instanceof RubyString) {

core/src/main/java/org/jruby/RubyIO.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4679,13 +4679,15 @@ public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyOb
46794679

46804680
int firstArg = 0;
46814681

4682-
if (argc > 0 && !TypeConverter.checkHashType(runtime, args[0]).isNil()) {
4683-
firstArg++;
4682+
// process trailing keyword arguments hash
4683+
if (argc > 0 && !(tmp = TypeConverter.checkHashType(runtime, args[argc - 1])).isNil()) {
4684+
options = (RubyHash)tmp;
46844685
argc--;
46854686
}
46864687

4687-
if (argc > 0 && !(tmp = TypeConverter.checkHashType(runtime, args[argc - 1])).isNil()) {
4688-
options = (RubyHash)tmp;
4688+
// process leading env hash
4689+
if (argc > 0 && !TypeConverter.checkHashType(runtime, args[0]).isNil()) {
4690+
firstArg++;
46894691
argc--;
46904692
}
46914693

core/src/main/java/org/jruby/RubyThread.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
import java.io.IOException;
3737
import java.io.Writer;
38-
import java.lang.management.ManagementFactory;
38+
3939
import java.lang.ref.WeakReference;
4040
import java.nio.ByteBuffer;
4141
import java.nio.channels.Channel;
@@ -1513,21 +1513,10 @@ public IRubyObject raise(ThreadContext context, IRubyObject[] args, Block block)
15131513
public IRubyObject native_thread_id(ThreadContext context) {
15141514
if (!isAlive()) return context.nil;
15151515

1516-
String encodedString = ManagementFactory.getRuntimeMXBean().getName();
1517-
int atIndex = encodedString.indexOf('@');
1518-
1519-
// Undocumented format: 1761769@localhost.localdomain
1520-
if (atIndex != -1) {
1521-
try {
1522-
int id = Integer.parseInt(encodedString.substring(0, atIndex));
1523-
1524-
return asFixnum(context, id);
1525-
} catch (NumberFormatException e) {
1526-
// if we fail to parse this we will just act like we don't support it
1527-
}
1528-
}
1516+
Thread nativeThread = getNativeThread();
1517+
if (nativeThread == null) return context.nil;
15291518

1530-
return context.nil; // Not supported or failed to extract id
1519+
return asFixnum(context, nativeThread.threadId());
15311520
}
15321521

15331522
private IRubyObject genericRaise(ThreadContext context, RubyThread currentThread, IRubyObject... args) {

core/src/main/java/org/jruby/ext/digest/RubyDigest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ public IRubyObject initialize_copy(ThreadContext context, IRubyObject obj) {
532532
from.checkFrozen();
533533

534534
try {
535-
this.algo = (MessageDigest) from.algo.clone();
535+
synchronized (from) {
536+
this.algo = (MessageDigest) from.algo.clone();
537+
}
536538
} catch (CloneNotSupportedException e) {
537539
String name = from.algo.getAlgorithm();
538540
throw typeError(context, "Could not initialize copy of digest (" + name + ")");
@@ -541,7 +543,7 @@ public IRubyObject initialize_copy(ThreadContext context, IRubyObject obj) {
541543
}
542544

543545
@JRubyMethod(name = {"update", "<<"})
544-
public IRubyObject update(IRubyObject obj) {
546+
public synchronized IRubyObject update(IRubyObject obj) {
545547
ByteList bytes = obj.convertToString().getByteList();
546548
algo.update(bytes.getUnsafeBytes(), bytes.getBegin(), bytes.getRealSize());
547549
return this;
@@ -553,7 +555,7 @@ public IRubyObject finish() {
553555
}
554556

555557
@JRubyMethod()
556-
public IRubyObject finish(ThreadContext context) {
558+
public synchronized IRubyObject finish(ThreadContext context) {
557559
IRubyObject digest = RubyString.newStringNoCopy(context.runtime, algo.digest());
558560
algo.reset();
559561
return digest;
@@ -581,13 +583,13 @@ public IRubyObject block_length(ThreadContext context) {
581583
}
582584

583585
@JRubyMethod()
584-
public IRubyObject reset() {
586+
public synchronized IRubyObject reset() {
585587
algo.reset();
586588
return this;
587589
}
588590

589591
@JRubyMethod()
590-
public IRubyObject bubblebabble(ThreadContext context) {
592+
public synchronized IRubyObject bubblebabble(ThreadContext context) {
591593
final byte[] digest = algo.digest();
592594
return newString(context, BubbleBabble.bubblebabble(digest, 0, digest.length));
593595
}

core/src/main/java/org/jruby/ir/targets/indy/InvokeSite.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,22 +1334,22 @@ MethodHandle buildAliasHandle(ThreadContext context, CacheEntry entry, IRubyObje
13341334
if (method instanceof PartialDelegatingMethod delegate) {
13351335
DynamicMethod innerMethod = delegate.getRealMethod();
13361336
mh = getHandle(context, self, new CacheEntry(innerMethod, entry.sourceModule, entry.token));
1337-
} else if (method instanceof AliasMethod alias) {
1338-
DynamicMethod innerMethod = alias.getRealMethod();
1339-
String name = alias.getName();
1340-
1341-
// Use a second site to mimic invocation from AliasMethod
1342-
MethodType type = type();
1343-
if (!functional) type = type.dropParameterTypes(1, 2);
1344-
InvokeSite innerSite = (InvokeSite) SelfInvokeSite.bootstrap(LOOKUP, "callFunctional:" + name, type, literalClosure ? 1 : 0, flags, file, line);
1345-
mh = innerSite.getHandle(context, self, new CacheEntry(innerMethod, entry.sourceModule, entry.token));
1346-
if (!functional) mh = MethodHandles.dropArguments(mh, 1, IRubyObject.class);
1347-
1348-
alias.setHandle(mh);
1349-
1350-
if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
1351-
LOG.info(name() + "\tbound directly through alias to " + Bootstrap.logMethod(method));
1352-
}
1337+
// } else if (method instanceof AliasMethod alias) {
1338+
// DynamicMethod innerMethod = alias.getRealMethod();
1339+
// String name = alias.getName();
1340+
//
1341+
// // Use a second site to mimic invocation from AliasMethod
1342+
// MethodType type = type();
1343+
// if (!functional) type = type.dropParameterTypes(1, 2);
1344+
// InvokeSite innerSite = (InvokeSite) SelfInvokeSite.bootstrap(LOOKUP, "callFunctional:" + name, type, literalClosure ? 1 : 0, flags, file, line);
1345+
// mh = innerSite.getHandle(context, self, new CacheEntry(innerMethod, entry.sourceModule, entry.token));
1346+
// if (!functional) mh = MethodHandles.dropArguments(mh, 1, IRubyObject.class);
1347+
//
1348+
// alias.setHandle(mh);
1349+
//
1350+
// if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) {
1351+
// LOG.info(name() + "\tbound directly through alias to " + Bootstrap.logMethod(method));
1352+
// }
13531353
}
13541354

13551355
return mh;

pom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"ant.version": '1.9.8',
7777
"asm.version": '9.7.1',
7878
"jar-dependencies.version": '0.4.1',
79-
"jffi.version": '1.3.14',
79+
"jffi.version": '1.3.15',
8080
"joda.time.version": '2.14.0')
8181

8282
plugin_management do

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ DO NOT MODIFY - GENERATED CODE
108108
<its.j2ee>j2ee*/pom.xml</its.j2ee>
109109
<its.osgi>osgi*/pom.xml</its.osgi>
110110
<jar-dependencies.version>0.4.1</jar-dependencies.version>
111-
<jffi.version>1.3.14</jffi.version>
111+
<jffi.version>1.3.15</jffi.version>
112112
<joda.time.version>2.14.0</joda.time.version>
113113
<jruby-launcher.version>1.1.6</jruby-launcher.version>
114114
<jruby.basedir>${project.basedir}</jruby.basedir>

spec/ruby/core/encoding/compatible_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@
557557
[Encoding, "\x82\xa0".dup.force_encoding("shift_jis"), Encoding::Shift_JIS],
558558
].should be_computed_by(:compatible?, /abc/)
559559
end
560+
561+
it "returns the Regexp's Encoding if the String is ASCII only and the Regexp is not" do
562+
r = Regexp.new("\xa4\xa2".dup.force_encoding("euc-jp"))
563+
Encoding.compatible?("hello".dup.force_encoding("utf-8"), r).should == Encoding::EUC_JP
564+
end
560565
end
561566

562567
describe "Encoding.compatible? String, Symbol" do
@@ -619,6 +624,15 @@
619624
Encoding.compatible?(/abc/, str).should == Encoding::US_ASCII
620625
end
621626

627+
it "returns the String's Encoding when the String is ASCII only with a different encoding" do
628+
r = Regexp.new("\xa4\xa2".dup.force_encoding("euc-jp"))
629+
Encoding.compatible?(r, "hello".dup.force_encoding("utf-8")).should == Encoding::UTF_8
630+
end
631+
632+
it "returns the Regexp's Encoding if the String has the same non-ASCII encoding" do
633+
r = Regexp.new("\xa4\xa2".dup.force_encoding("euc-jp"))
634+
Encoding.compatible?(r, "hello".dup.force_encoding("euc-jp")).should == Encoding::EUC_JP
635+
end
622636
end
623637

624638
describe "Encoding.compatible? Regexp, Regexp" do

0 commit comments

Comments
 (0)