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: fae1a9608829
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 49b9caa8e2ae
Choose a head ref

Commits on Aug 21, 2016

  1. Copy the full SHA
    701683e View commit details

Commits on Aug 22, 2016

  1. add specs for non-ASCII symbols

    phluid61 committed Aug 22, 2016
    Copy the full SHA
    12d85c1 View commit details
  2. Copy the full SHA
    48f2b21 View commit details

Commits on Sep 1, 2017

  1. an example test case for #4770 that shows how unicode readings fails …

    …in readonly transaction
    duritong committed Sep 1, 2017
    Copy the full SHA
    63be5a4 View commit details

Commits on Jan 10, 2018

  1. Copy the full SHA
    c0741fa View commit details
  2. Fix Hash#rehash method for duplicate keys

    Duplicate keys where just ignored before and inserted again.
    Fix #4958.
    ChrisBr committed Jan 10, 2018
    Copy the full SHA
    2a7d600 View commit details
  3. Merge pull request #4096 from brocktimus/stickers_symbols_with_encoding

    Extra tests for symbol encoding Re: #4070 + #3719 and possibly #3880
    kares authored Jan 10, 2018
    Copy the full SHA
    4ec3759 View commit details
  4. Merge pull request #4099 from phluid61/feature/unicode-symbol-spec

    specs for Unicode symbols
    kares authored Jan 10, 2018
    Copy the full SHA
    27bf29d View commit details
  5. Merge pull request #4771 from duritong/yamlstore-unicode-failure-in-r…

    …eadonly-transaction
    
    an example test case for #4770 that shows how unicode readings fails …
    enebo authored Jan 10, 2018
    Copy the full SHA
    06aa3f7 View commit details
  6. Merge pull request #4961 from ChrisBr/bug/rehash

    Fix Hash#rehash method for duplicate keys
    headius authored Jan 10, 2018
    Copy the full SHA
    80efaf4 View commit details
  7. Copy the full SHA
    deee6cc View commit details

Commits on Jan 11, 2018

  1. Copy the full SHA
    ccac3db View commit details
  2. Copy the full SHA
    72be3db View commit details
  3. Copy the full SHA
    d6ef4a3 View commit details
  4. Copy the full SHA
    a77b77b View commit details
  5. Copy the full SHA
    b70c8f5 View commit details
  6. Copy the full SHA
    eb7db5a View commit details
  7. Copy the full SHA
    60c7a27 View commit details
  8. Copy the full SHA
    3f39d54 View commit details

Commits on Jan 12, 2018

  1. Copy the full SHA
    c9790ea View commit details
  2. Copy the full SHA
    ebb0f60 View commit details
  3. Made method storage backed by ByteList instead of String. I knew this…

    … day
    
    would come but I was hoping I could cheat with 8859_1 strings enough to merge
    for 9.2.  Unfortunately, lack of encoding through method methods means we cannot
    accurately throw properly encoded error messages since he have long lost the
    encoding of the method.
    
    So with that said, most people will not be able to notice this change.  All the
    String methods for methods still exist.  These methods will assume all data is
    UTF-8.  This could be a dicey gamble but since it is the default for Ruby it
    likely will not impact anyone.  Also since UTF-8 is 7bit clean for ASCII we
    should totally not have an issue there.
    
    Some API signatures have changed.  This means 9.2 might end up causing some
    issues if you are doing something very low-level with our code base (although
    changes up to this point have already broken some APIs within parsing and IR
    and that is unavoidable).  The method reader/writer maps needed their return
    type changed from <String, DynamicMethod> to <ByteList, DynamicMethod>.  It
    was an option to make a new name for methods which returned this but this is
    so far down in our APIs I think we should run with it.  Also ProfiledMethod
    has changed from String to ByteList (e.g. getName() -> ByteList from String).
    Ultimately ProfiledMethod needs to be properly encoded to be able to report
    the method in a properly encoded way...so there you have it.
    
    Next phase is to change interpreters and the JIT to stop from going:
    ByteList -> String -> ByteList.  I did not do that part here since this is
    pretty large already.
    enebo committed Jan 12, 2018
    Copy the full SHA
    7004a17 View commit details

Commits on Jan 14, 2018

  1. Extract parseRegexpFlags to Lexer

    And use the same function from both Ripper and main parser.
    grddev committed Jan 14, 2018
    Copy the full SHA
    0829a85 View commit details
  2. Move Regexp checking from ParserSupport to Lexer

    While not really related to Lexing, this is a component that is shared between Ripper and the main parser, and that seemed like the lesser evil.
    grddev committed Jan 14, 2018
    Copy the full SHA
    54a483b View commit details
  3. Align validation code with MRI

    It seems to have been `!ENCODING_IS_ASCII8BIT(str)` from the beginning, so I'm not sure why it was the opposite here.
    grddev committed Jan 14, 2018
    Copy the full SHA
    57661ef View commit details
  4. Make sure to clear $! when rescuing RaiseException

    The code was copied from Parser support, so it was clearly broken before, but it had to be fixed now as parts of the Ripper test suite relies on $! rather than explicitly catching the exception.
    grddev committed Jan 14, 2018
    Copy the full SHA
    a089f8a View commit details
  5. Add support for validating Regexp in Ripper

    This uses the fact that Regexp tokenization is handled by a single StringTerm, and thus all tSTRING_CONTENT fragments are easily collectable until the tREGEXP_END comes with the options that we need for validation.
    
    The validation itself is a copied/simplified version of what is performed by the main parser, as large parts the validation depended on the AST structure, which we do not have here.
    
    Technically, this doesn't perform the validation at the same point in time as the main parser, as it performs the validation when encountering the tREGEXP_END token rather than when processing the regexp rule.
    
    I speculate that the difference doesn't really matter given that the only thing we could do with the tREGEXP_END token is to apply the regexp rule.
    grddev committed Jan 14, 2018
    Copy the full SHA
    38d526b View commit details
  6. Simplify the regexp validation logic

    Use a separate variable to track whether things are dynamic or not, and use a List to avoid tracking the last element explicitly.
    grddev committed Jan 14, 2018
    Copy the full SHA
    d3a8051 View commit details
  7. Inline the regexp validation inside ParserSupport

    The methods were only retained to provide the old interface, but by directly calling the new methods in the Lexer, we can remove the old methods, given that we don't really need to be backwards compatible here.
    grddev committed Jan 14, 2018
    Copy the full SHA
    836f80e View commit details
  8. Merge pull request #4902 from grddev/ripper-regex

    Add support for validating Regexp in Ripper
    enebo authored Jan 14, 2018
    Copy the full SHA
    2614c77 View commit details

Commits on Jan 15, 2018

  1. Remove not used methods (#4973)

    yui-knk authored and kares committed Jan 15, 2018
    Copy the full SHA
    d42f53e View commit details
  2. Fix a typo

    yui-knk committed Jan 15, 2018
    Copy the full SHA
    a50a13b View commit details
  3. Merge pull request #4977 from yui-knk/typo

    Fix a typo
    mkristian authored Jan 15, 2018
    Copy the full SHA
    7bd2b2c View commit details
  4. use num2int in StringIO#ungetc

    lopex committed Jan 15, 2018
    Copy the full SHA
    ddfee9d View commit details

Commits on Jan 16, 2018

  1. Revise COPYRIGHT YEAR

    A happy new year! 🎆🎍
    BanzaiMan committed Jan 16, 2018
    Copy the full SHA
    817d60c View commit details
  2. Fix documents

    `findEncodingNoError` does not raise any error.
    yui-knk committed Jan 16, 2018
    Copy the full SHA
    577cc2f View commit details
  3. Merge pull request #4979 from yui-knk/fix_doc

    Fix documents
    enebo authored Jan 16, 2018
    Copy the full SHA
    baf2bf6 View commit details
  4. fix IOOBE in test_regexp quote

    lopex committed Jan 16, 2018
    Copy the full SHA
    0c7f44a View commit details
  5. Copy the full SHA
    c95e294 View commit details
  6. raise ArgumentError

    lopex committed Jan 16, 2018
    Copy the full SHA
    8be11ed View commit details

Commits on Jan 17, 2018

  1. introduce long overloads for common (integer) ops + start using them

    ... as a side effect op_pow(long) got resurrected for Fixnum/Bignum
    kares committed Jan 17, 2018
    Copy the full SHA
    e0de0f0 View commit details
  2. Copy the full SHA
    73eeb44 View commit details
  3. Copy the full SHA
    363aa82 View commit details
  4. Copy the full SHA
    8723a89 View commit details
  5. Mild refactoring of invokers code (came from bytelist_love work). As …

    …I need
    
    to make changes to generated code I am trying to comment/document some portions
    and reduce some duplication when possible.
    enebo committed Jan 17, 2018
    Copy the full SHA
    4a34053 View commit details
  6. Copy the full SHA
    49b9caa View commit details
Showing with 845 additions and 553 deletions.
  1. +1 −1 BUILDING.md
  2. +1 −1 COPYING
  3. +0 −4 core/src/main/java/org/jruby/IncludedModule.java
  4. +5 −8 core/src/main/java/org/jruby/IncludedModuleWrapper.java
  5. +3 −2 core/src/main/java/org/jruby/PrependedModule.java
  6. +7 −6 core/src/main/java/org/jruby/Ruby.java
  7. +3 −3 core/src/main/java/org/jruby/RubyBasicObject.java
  8. +37 −29 core/src/main/java/org/jruby/RubyBignum.java
  9. +13 −5 core/src/main/java/org/jruby/RubyClass.java
  10. +21 −14 core/src/main/java/org/jruby/RubyFixnum.java
  11. +11 −2 core/src/main/java/org/jruby/RubyHash.java
  12. +7 −8 core/src/main/java/org/jruby/RubyIO.java
  13. +13 −1 core/src/main/java/org/jruby/RubyInteger.java
  14. +117 −62 core/src/main/java/org/jruby/RubyModule.java
  15. +5 −1 core/src/main/java/org/jruby/RubyNumeric.java
  16. +15 −21 core/src/main/java/org/jruby/RubyRational.java
  17. +7 −3 core/src/main/java/org/jruby/RubyRegexp.java
  18. +50 −50 core/src/main/java/org/jruby/RubyString.java
  19. +1 −1 core/src/main/java/org/jruby/RubySymbol.java
  20. +1 −10 core/src/main/java/org/jruby/anno/IndyBinder.java
  21. +22 −0 core/src/main/java/org/jruby/anno/MethodDescriptor.java
  22. +18 −0 core/src/main/java/org/jruby/ext/ripper/RipperLexer.java
  23. +33 −24 core/src/main/java/org/jruby/ext/ripper/StringTerm.java
  24. +14 −0 core/src/main/java/org/jruby/ext/set/RubySortedSet.java
  25. +1 −1 core/src/main/java/org/jruby/ext/stringio/StringIO.java
  26. +9 −3 core/src/main/java/org/jruby/internal/runtime/methods/AliasMethod.java
  27. +5 −21 core/src/main/java/org/jruby/internal/runtime/methods/InvocationMethodFactory.java
  28. +1 −1 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
  29. +12 −10 core/src/main/java/org/jruby/java/util/BlankSlateWrapper.java
  30. +10 −10 core/src/main/java/org/jruby/javasupport/JavaPackage.java
  31. +16 −13 core/src/main/java/org/jruby/javasupport/proxy/JavaProxyClass.java
  32. +121 −0 core/src/main/java/org/jruby/lexer/LexingCommon.java
  33. +18 −0 core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
  34. +1 −51 core/src/main/java/org/jruby/lexer/yacc/StringTerm.java
  35. +7 −74 core/src/main/java/org/jruby/parser/ParserSupport.java
  36. +1 −1 core/src/main/java/org/jruby/runtime/Frame.java
  37. +23 −62 core/src/main/java/org/jruby/runtime/Helpers.java
  38. +8 −8 core/src/main/java/org/jruby/runtime/MethodIndex.java
  39. +1 −1 core/src/main/java/org/jruby/runtime/ThreadContext.java
  40. +1 −1 core/src/main/java/org/jruby/runtime/encoding/EncodingService.java
  41. +2 −1 core/src/main/java/org/jruby/runtime/profile/MethodEnhancer.java
  42. +4 −0 core/src/main/java/org/jruby/runtime/profile/ProfilingService.java
  43. +9 −3 core/src/main/java/org/jruby/runtime/profile/builtin/BuiltinProfilingService.java
  44. +11 −14 core/src/main/java/org/jruby/runtime/profile/builtin/ProfilePrinter.java
  45. +4 −3 core/src/main/java/org/jruby/runtime/profile/builtin/ProfiledMethod.java
  46. +7 −2 core/src/main/java/org/jruby/runtime/profile/builtin/ProfiledMethods.java
  47. +2 −0 core/src/main/java/org/jruby/util/CommonByteLists.java
  48. +2 −2 core/src/main/java/org/jruby/util/Numeric.java
  49. +1 −1 core/src/main/java/org/jruby/util/RegexpSupport.java
  50. +3 −3 core/src/main/java/org/jruby/util/RubyDateFormatter.java
  51. +16 −1 core/src/main/java/org/jruby/util/StringSupport.java
  52. +4 −4 rakelib/test.rake
  53. +96 −4 spec/regression/symbol_encoding_spec.rb
  54. +15 −0 spec/ruby/core/hash/rehash_spec.rb
  55. +11 −0 test/jruby/test_set.rb
  56. +18 −0 test/jruby/test_yamlstore.rb
  57. +0 −1 test/mri/excludes/TestRipper/Ripper.rb
  58. +0 −1 test/mri/excludes/TestRipper/Sexp.rb
2 changes: 1 addition & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ verify that JRuby is still fully functional.

### Hacking the Build System

for a general overview of the different directories and maven artifacts see [JRuby Build)](https://github.com/jruby/jruby/wiki/JRuby-Build----Some-Inside-Info)
for a general overview of the different directories and maven artifacts see [JRuby Build](https://github.com/jruby/jruby/wiki/JRuby-Build----Some-Inside-Info)

For this only the ***pom.rb*** needs to edited. using mvn-3.3.x or the maven wrapper `./mvnw` will generate the pom.xml file where needed. For the jar files of the build those pom.xml will be generated for some use-cases, i.e. some IDEs need them.

2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
JRuby is Copyright (c) 2007-2017 The JRuby project, and is released
JRuby is Copyright (c) 2007-2018 The JRuby project, and is released
under a tri EPL/GPL/LGPL license. You can use it, redistribute it
and/or modify it under the terms of the:

4 changes: 0 additions & 4 deletions core/src/main/java/org/jruby/IncludedModule.java
Original file line number Diff line number Diff line change
@@ -34,10 +34,6 @@ public void setMetaClass(RubyClass newRubyClass) {
throw new UnsupportedOperationException("An included class is only a wrapper for a module");
}

public void setMethods(Map newMethods) {
throw new UnsupportedOperationException("An included class is only a wrapper for a module");
}

@Override
public String getName() {
return origin.getName();
13 changes: 5 additions & 8 deletions core/src/main/java/org/jruby/IncludedModuleWrapper.java
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.builtin.Variable;
import org.jruby.util.ByteList;

/**
* This class is used to provide an intermediate superclass for modules and classes that include
@@ -85,10 +86,6 @@ public void addMethod(String name, DynamicMethod method) {
throw new UnsupportedOperationException("An included class is only a wrapper for a module");
}

public void setMethods(Map newMethods) {
throw new UnsupportedOperationException("An included class is only a wrapper for a module");
}

public RubyModule getDelegate() {
return origin;
}
@@ -109,12 +106,12 @@ protected boolean isSame(RubyModule module) {
}

@Override
public Map<String, DynamicMethod> getMethods() {
public Map<ByteList, DynamicMethod> getMethods() {
return origin.getMethods();
}

@Override
public Map<String, DynamicMethod> getMethodsForWrite() {
public Map<ByteList, DynamicMethod> getMethodsForWrite() {
return origin.getMethodsForWrite();
}

@@ -211,7 +208,7 @@ protected IRubyObject getAutoloadConstant(String name, boolean forceLoad) {
}

@Override
protected DynamicMethod searchMethodCommon(String name) {
protected DynamicMethod searchMethodCommon(ByteList name) {
// IncludedModuleWrapper needs to search prepended modules too, so search until we find methodLocation
RubyModule module = origin;
RubyModule methodLoc = origin.getMethodLocation();
@@ -229,7 +226,7 @@ protected DynamicMethod searchMethodCommon(String name) {
}

@Override
protected void addMethodSymbols(Ruby runtime, Set<String> seen, RubyArray ary, boolean not, Visibility visibility) {
protected void addMethodSymbols(Ruby runtime, Set<ByteList> seen, RubyArray ary, boolean not, Visibility visibility) {
// IncludedModuleWrapper needs to search prepended modules too, so search until we find methodLocation
RubyModule module = origin;
RubyModule methodLoc = origin.getMethodLocation();
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/PrependedModule.java
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
import java.util.concurrent.ConcurrentHashMap;

import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.util.ByteList;

/**
* This class is used as an intermediate superclass for Module#prepend
@@ -44,9 +45,9 @@ public class PrependedModule extends IncludedModule {
public PrependedModule(Ruby runtime, RubyClass superClass, RubyModule origin) {
super(runtime, superClass, origin);
methods = origin.methods;
origin.methods = new ConcurrentHashMap<String, DynamicMethod>(0, 0.9f, 1);
origin.methods = new ConcurrentHashMap<>(0, 0.9f, 1);
origin.methodLocation = this;
for (Map.Entry<String, DynamicMethod> entry : methods.entrySet()) {
for (Map.Entry<ByteList, DynamicMethod> entry : methods.entrySet()) {
DynamicMethod method = entry.getValue();
method.setImplementationClass(this);
method.setDefinedClass(origin);
13 changes: 7 additions & 6 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.invokedynamic.InvokeDynamicSupport;
import org.jruby.util.MRIRecursionGuard;
import org.jruby.util.StringSupport;
import org.jruby.util.StrptimeParser;
import org.jruby.util.StrptimeToken;
import org.jruby.util.io.EncodingUtils;
@@ -3022,14 +3023,14 @@ public void addBoundMethod(String className, String methodName, String rubyName)
}

public void addBoundMethodsPacked(String className, String packedTuples) {
String[] names = Helpers.SEMICOLON_PATTERN.split(packedTuples);
for (int i = 0; i < names.length; i += 2) {
addBoundMethod(className, names[i], names[i+1]);
List<String> names = StringSupport.split(packedTuples, ';');
for (int i = 0; i < names.size(); i += 2) {
addBoundMethod(className, names.get(i), names.get(i+1));
}
}

public void addSimpleBoundMethodsPacked(String className, String packedNames) {
String[] names = Helpers.SEMICOLON_PATTERN.split(packedNames);
List<String> names = StringSupport.split(packedNames, ';');
for (String name : names) {
addBoundMethod(className, name, name);
}
@@ -4492,7 +4493,7 @@ public List<StrptimeToken> getCachedStrptimePattern(String pattern) {
* @param name the name of the method
* @param method
*/
void addProfiledMethod(final String name, final DynamicMethod method) {
void addProfiledMethod(final ByteList name, final DynamicMethod method) {
if (!config.isProfiling()) return;
if (method.isUndefined()) return;

@@ -5145,7 +5146,7 @@ private MRIRecursionGuard oldRecursionGuard() {
private EnumMap<RubyThread.Status, RubyString> threadStatuses = new EnumMap<RubyThread.Status, RubyString>(RubyThread.Status.class);

public interface ObjectSpacer {
public void addToObjectSpace(Ruby runtime, boolean useObjectSpace, IRubyObject object);
void addToObjectSpace(Ruby runtime, boolean useObjectSpace, IRubyObject object);
}

private static final ObjectSpacer DISABLED_OBJECTSPACE = new ObjectSpacer() {
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -2371,7 +2371,7 @@ public IRubyObject methods19(ThreadContext context, IRubyObject[] args) {

final IRubyObject methodsImpl(ThreadContext context, final boolean all) {
final RubyArray methods = RubyArray.newArray(context.runtime);
final Set<String> seen = new HashSet<>();
final Set<ByteList> seen = new HashSet<>();

RubyClass metaClass = getMetaClass();
if (metaClass.isSingleton()) {
@@ -2495,7 +2495,7 @@ public RubyArray singleton_methods(ThreadContext context, IRubyObject[] args) {

if (klass.isSingleton()) {
Set<RubySymbol> names = new HashSet<>();
for (Map.Entry<String, DynamicMethod> entry : klass.getMethods().entrySet()) {
for (Map.Entry<ByteList, DynamicMethod> entry : klass.getMethods().entrySet()) {
if (entry.getValue().getVisibility() == PRIVATE) continue;
// TODO: needs to use method_entry_i logic from MRI
names.add(runtime.newSymbol(entry.getKey()));
@@ -2505,7 +2505,7 @@ public RubyArray singleton_methods(ThreadContext context, IRubyObject[] args) {
klass = klass.getSuperClass();
while (klass != null && (klass.isSingleton() || klass.isIncluded())) {
if (klass != origin) {
for (Map.Entry<String, DynamicMethod> entry : klass.getMethods().entrySet()) {
for (Map.Entry<ByteList, DynamicMethod> entry : klass.getMethods().entrySet()) {
if (entry.getValue().getVisibility() == PRIVATE) continue;
// TODO: needs to use method_entry_i logic from MRI
names.add(runtime.newSymbol(entry.getKey()));
66 changes: 37 additions & 29 deletions core/src/main/java/org/jruby/RubyBignum.java
Original file line number Diff line number Diff line change
@@ -438,6 +438,7 @@ public IRubyObject op_plus(ThreadContext context, IRubyObject other) {
return addOther(context, other);
}

@Override
public final IRubyObject op_plus(ThreadContext context, long other) {
BigInteger result = value.add(BigInteger.valueOf(other));
if (other > 0 && value.signum() > 0) return new RubyBignum(context.runtime, result);
@@ -475,6 +476,7 @@ public IRubyObject op_minus(ThreadContext context, IRubyObject other) {
return subtractOther(context, other);
}

@Override
public final IRubyObject op_minus(ThreadContext context, long other) {
BigInteger result = value.subtract(BigInteger.valueOf(other));
if (value.signum() < 0 && other > 0) return new RubyBignum(context.runtime, result);
@@ -517,6 +519,7 @@ public final IRubyObject op_mul19(ThreadContext context, IRubyObject other) {
return op_mul(context, other);
}

@Override
public final IRubyObject op_mul(ThreadContext context, long other) {
return bignorm(context.runtime, value.multiply(long2big(other)));
}
@@ -546,6 +549,10 @@ private IRubyObject op_divide(ThreadContext context, IRubyObject other, boolean
return coerceBin(context, slash ? sites(context).op_quo : sites(context).div, other);
}

return divideImpl(runtime, otherValue);
}

private RubyInteger divideImpl(Ruby runtime, BigInteger otherValue) {
if (otherValue.signum() == 0) throw runtime.newZeroDivisionError();

final BigInteger result;
@@ -566,6 +573,10 @@ public IRubyObject op_div(ThreadContext context, IRubyObject other) {
return op_divide(context, other, true);
}

public IRubyObject op_div(ThreadContext context, long other) {
return divideImpl(context.runtime, long2big(other));
}

/** rb_big_idiv
*
*/
@@ -574,6 +585,11 @@ public IRubyObject idiv(ThreadContext context, IRubyObject other) {
return op_divide(context, other, false);
}

@Override
public IRubyObject idiv(ThreadContext context, long other) {
return divideImpl(context.runtime, long2big(other));
}

/** rb_big_divmod
*
*/
@@ -716,32 +732,37 @@ public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
d = ((RubyBignum) other).getDoubleValue();
context.runtime.getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
} else if (other instanceof RubyFixnum) {
long yy = other.convertToInteger().getLongValue();
if (yy < 0)
return RubyRational.newRationalRaw(runtime, this).op_expt(context, other);
else {
int xbits = value.bitLength();
int BIGLEN_LIMIT = 32*1024*1024;

if ((xbits > BIGLEN_LIMIT) ||
(xbits * yy > BIGLEN_LIMIT)) {
runtime.getWarnings().warn("in a**b, b may be too big");
d = (double)yy;
}
else {
return newBignum(runtime, value.pow((int)yy));
}
}
return op_pow(context, other.convertToInteger().getLongValue());
} else {
return coerceBin(context, sites(context).op_exp, other);
}
return pow(runtime, d);
}

private RubyNumeric pow(final Ruby runtime, final double d) {
double pow = Math.pow(big2dbl(this), d);
if (Double.isInfinite(pow)) {
return RubyFloat.newFloat(runtime, pow);
}
return RubyNumeric.dbl2ival(runtime, pow);
}

private static final int BIGLEN_LIMIT = 32 * 1024 * 1024;

public final IRubyObject op_pow(final ThreadContext context, final long other) {
if (other < 0) {
return RubyRational.newRationalRaw(context.runtime, this).op_expt(context, other);
}
final int xbits = value.bitLength();
if ((xbits > BIGLEN_LIMIT) || (xbits * other > BIGLEN_LIMIT)) {
context.runtime.getWarnings().warn("in a**b, b may be too big");
return pow(context.runtime, (double) other);
}
else {
return newBignum(context.runtime, value.pow((int) other));
}
}

private void warnIfPowExponentTooBig(final ThreadContext context, final long other) {
// MRI issuses warning here on (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024)
if ( ((value.bitLength() + 7) / 8) * 4 * Math.abs((double) other) > 1024 * 1024 ) {
@@ -1124,19 +1145,6 @@ public boolean isImmediate() {
return true;
}

@Deprecated
public final IRubyObject op_pow(final ThreadContext context, final long other) {
if (other >= 0) {
if (other <= Integer.MAX_VALUE) { // only have BigInteger#pow(int)
return bignorm(context.runtime, value.pow((int) other)); // num2int is also implemented
}
warnIfPowExponentTooBig(context, other);
return RubyFloat.newFloat(context.runtime, Math.pow(big2dbl(this), (double) other));
}
// (other < 0)
return RubyRational.newRationalRaw(context.runtime, this).op_expt(context, other);
}

private static JavaSites.BignumSites sites(ThreadContext context) {
return context.sites.Bignum;
}
18 changes: 13 additions & 5 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
@@ -87,10 +87,12 @@
import org.jruby.runtime.marshal.UnmarshalStream;
import org.jruby.runtime.opto.Invalidator;
import org.jruby.util.ArraySupport;
import org.jruby.util.ByteList;
import org.jruby.util.OneShotClassLoader;
import org.jruby.util.ClassDefiningClassLoader;
import org.jruby.util.CodegenUtils;
import org.jruby.util.JavaNameMangler;
import org.jruby.util.StringSupport;
import org.jruby.util.collections.WeakHashSet;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
@@ -1552,10 +1554,13 @@ byte[] reify(final String javaName, final String javaPath) {
final Set<String> instanceMethods = new HashSet<String>(getMethods().size());

// define instance methods
for (Map.Entry<String,DynamicMethod> methodEntry : getMethods().entrySet()) {
final String methodName = methodEntry.getKey();
for (Map.Entry<ByteList, DynamicMethod> methodEntry : getMethods().entrySet()) {
final ByteList name = methodEntry.getKey();
// Since we are reifying to a Java type we should be using method names which are representable
// as a Java charset. If this is not the case we should add some error check or skip those entries?
String methodName = StringSupport.byteListAsString(name);

if ( ! JavaNameMangler.willMethodMangleOk(methodName) ) {
if (!JavaNameMangler.willMethodMangleOk(methodName)) {
LOG.debug("{} method: '{}' won't be part of reified Java class", getName(), methodName);
continue;
}
@@ -1662,8 +1667,11 @@ byte[] reify(final String javaName, final String javaPath) {
}

// define class/static methods
for (Map.Entry<String,DynamicMethod> methodEntry : getMetaClass().getMethods().entrySet()) {
String methodName = methodEntry.getKey();
for (Map.Entry<ByteList,DynamicMethod> methodEntry : getMetaClass().getMethods().entrySet()) {
ByteList name = methodEntry.getKey();
// Since we are reifying to a Java type we should be using method names which are representable
// as a Java charset. If this is not the case we should add some error check or skip those entries?
String methodName = StringSupport.byteListAsString(name);

if (!JavaNameMangler.willMethodMangleOk(methodName)) continue;

Loading