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: 1fec405b9ac4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b07a5845574d
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 27, 2018

  1. Copy the full SHA
    7763dfa View commit details
  2. Copy the full SHA
    b07a584 View commit details
Showing with 14 additions and 5 deletions.
  1. +4 −4 core/src/main/java/org/jruby/ext/date/RubyDate.java
  2. +10 −1 core/src/main/java/org/jruby/javasupport/ext/JavaLang.java
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/ext/date/RubyDate.java
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ public IRubyObject initialize_copy(IRubyObject original) {
/**
* @deprecated internal Date.new!
*/
@JRubyMethod(name = "new!", meta = true)
@JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE)
public static RubyDate new_(ThreadContext context, IRubyObject self) {
if (self == getDateTime(context.runtime)) {
return new RubyDateTime(context.runtime, 0, CHRONO_ITALY_UTC);
@@ -304,7 +304,7 @@ public static RubyDate new_(ThreadContext context, IRubyObject self) {
/**
* @deprecated internal Date.new!
*/
@JRubyMethod(name = "new!", meta = true)
@JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE)
public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject ajd) {
if (ajd instanceof JavaProxy) { // backwards - compatibility with JRuby's date.rb
if (self == getDateTime(context.runtime)) {
@@ -321,7 +321,7 @@ public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject
/**
* @deprecated internal Date.new!
*/
@JRubyMethod(name = "new!", meta = true)
@JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE)
public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of) {
if (self == getDateTime(context.runtime)) {
return new RubyDateTime(context.runtime, (RubyClass) self).initialize(context, ajd, of);
@@ -332,7 +332,7 @@ public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject
/**
* @deprecated internal Date.new!
*/
@JRubyMethod(name = "new!", meta = true)
@JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE)
public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of, IRubyObject sg) {
if (self == getDateTime(context.runtime)) {
return new RubyDateTime(context.runtime, (RubyClass) self).initialize(context, ajd, of, sg);
11 changes: 10 additions & 1 deletion core/src/main/java/org/jruby/javasupport/ext/JavaLang.java
Original file line number Diff line number Diff line change
@@ -371,8 +371,17 @@ public static IRubyObject integer_p(final ThreadContext context, final IRubyObje

@JRubyMethod(name = "zero?")
public static IRubyObject zero_p(final ThreadContext context, final IRubyObject self) {
return context.runtime.newBoolean(isZero(self));
}

private static boolean isZero(final IRubyObject self) {
java.lang.Number val = (java.lang.Number) self.toJava(java.lang.Number.class);
return context.runtime.newBoolean(Double.compare(val.doubleValue(), 0) == 0);
return Double.compare(val.doubleValue(), 0) == 0;
}

@JRubyMethod(name = "nonzero?")
public static IRubyObject nonzero_p(final ThreadContext context, final IRubyObject self) {
return isZero(self) ? context.nil : self;
}

@JRubyMethod(name = "coerce")