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

Commits on Dec 10, 2016

  1. Copy the full SHA
    bbfa92e View commit details
  2. Copy the full SHA
    04287d8 View commit details
  3. [Truffle] Rename for clarity.

    eregon committed Dec 10, 2016
    Copy the full SHA
    98d3f35 View commit details
  4. [Truffle] Simplify and inline.

    * GregorianCalendar.from(ZonedDateTime) already has the right defaults.
    eregon committed Dec 10, 2016
    Copy the full SHA
    9281dcb View commit details
  5. Copy the full SHA
    b9b7586 View commit details
  6. [Truffle] We no longer need joda-time.

    * Java 8's time API is used instead.
    eregon committed Dec 10, 2016
    Copy the full SHA
    c9eb0d8 View commit details
14 changes: 0 additions & 14 deletions mx.jruby/suite.py
Original file line number Diff line number Diff line change
@@ -140,23 +140,11 @@ def mavenLib(mavenDep, sha1, sourceSha1, license):
"2982d6beb2f8fabe5ac5cc9dec6b4d6a9ffeedb1",
"MIT"),

"BYTELIST": mavenLib(
"org.jruby.extras:bytelist:1.0.13",
"dc54989113128bda0d303c7bf97a7aba65507ddf",
"e8f683aa496bf651879d9e3a8a82e053c2df9b99",
"EPL-1.0"),

"JCODINGS": mavenLib(
"org.jruby.jcodings:jcodings:1.0.18",
"e2c76a19f00128bb1806207e2989139bfb45f49d",
"201985f0f15af95f03494ab9ef0400e849090d6c",
"MIT"),

"JODA_TIME": mavenLib(
"joda-time:joda-time:2.8.2",
"d27c24204c5e507b16fec01006b3d0f1ec42aed4",
"65dd2b998571ea61a3cee68c99a1dde729b14a7e",
"Apache-2.0"),
},

"projects": {
@@ -177,9 +165,7 @@ def mavenLib(mavenDep, sha1, sourceSha1, license):
"JFFI_NATIVE",
"SNAKEYAML",
"JONI",
"BYTELIST",
"JCODINGS",
"JODA_TIME",
],
"annotationProcessors": ["truffle:TRUFFLE_DSL_PROCESSOR"],
"javaCompliance": "1.8",
1 change: 0 additions & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@
jar 'org.yaml:snakeyaml:1.14'
jar 'org.jruby.joni:joni:2.1.11'
jar 'org.jruby.jcodings:jcodings:1.0.18'
jar 'joda-time:joda-time:2.8.2'

jar 'junit:junit', :scope => 'test'

5 changes: 0 additions & 5 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -87,11 +87,6 @@ DO NOT MODIFIY - GENERATED CODE
<artifactId>jcodings</artifactId>
<version>1.0.18</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Original file line number Diff line number Diff line change
@@ -15,21 +15,15 @@

import com.oracle.truffle.api.source.Source;
import org.jcodings.exception.InternalException;
import org.joda.time.DateTimeZone;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.language.loader.SourceLoader;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.DateFormatSymbols;
import java.util.Locale;

// Checkstyle: stop

@@ -62,29 +56,6 @@ static DataInputStream openStream(String name) {
}
}

@SuppressWarnings("static-method")
final class Target_org_joda_time_tz_ZoneInfoProvider {
File iFileDir;

DateTimeZone getZone(String id) {
return JRubySupport.allTimeZones.get(id);
}

InputStream openResource(String name) throws IOException {
if (iFileDir != null) {
return new FileInputStream(new File(iFileDir, name));
} else {
throw new IllegalArgumentException("Not supported on SubstrateVM");
}
}
}

final class Target_org_joda_time_DateTimeUtils {
static DateFormatSymbols getDateFormatSymbols(Locale locale) {
return DateFormatSymbols.getInstance(locale);
}
}

final class Target_org_jruby_truffle_core_string_StringSupport {
static int ARRAY_BYTE_BASE_OFFSET;
}
38 changes: 0 additions & 38 deletions truffle/src/main/java/org/jruby/truffle/aot/JRubySupport.java
Original file line number Diff line number Diff line change
@@ -17,9 +17,6 @@
import org.jcodings.EncodingDB;
import org.jcodings.util.ArrayReader;
import org.jcodings.util.CaseInsensitiveBytesHash;
import org.joda.time.DateTimeZone;
import org.joda.time.tz.DateTimeZoneBuilder;
import org.joda.time.tz.ZoneInfoProvider;

import java.io.DataInputStream;
import java.io.IOException;
@@ -35,44 +32,9 @@
import java.util.regex.Pattern;

public final class JRubySupport {
public static final Map<String, DateTimeZone> allTimeZones = getTimeZones();
public static final Map<String, EncodingInstance> allEncodings = getEncodings();
public static final Map<String, byte[]> allJCodingsTables = getJcodingsTables();

private static Map<String, DateTimeZone> getTimeZones() {
Map<String, DateTimeZone> timeZones = new HashMap<>();

// read in ZoneInfoMap to determine available timezones
Map<String, Object> zoneInfoMap = new HashMap<>();
try {
String resourcePath = "org/joda/time/tz/data/";
java.lang.reflect.Method readZoneInfoMap = ZoneInfoProvider.class.getDeclaredMethod("readZoneInfoMap", DataInputStream.class, Map.class);
readZoneInfoMap.setAccessible(true);
try (DataInputStream mapIn = new DataInputStream(ClassLoader.getSystemResourceAsStream(resourcePath + "ZoneInfoMap"))) {
readZoneInfoMap.invoke(null, mapIn, zoneInfoMap);
}
// preload all DateTimeZone objects
for (Map.Entry<String, Object> e : zoneInfoMap.entrySet()) {
Object value = e.getValue();
if (value instanceof String) {
String id = (String) value;
String path = resourcePath + id;
try (InputStream zoneIn = ClassLoader.getSystemResourceAsStream(path)) {
if (zoneIn != null) {
timeZones.put(e.getKey(), DateTimeZoneBuilder.readFrom(zoneIn, id));
} else {
throw new Error("Unable to load timezone " + id);
}
} catch (IOException ex) {
}
}
}
} catch (Exception e) {
}
timeZones.put("UTC", DateTimeZone.UTC);
return timeZones;
}

private static Map<String, EncodingInstance> getEncodings() {
final Map<String, EncodingInstance> encodings = new HashMap<>();
final CaseInsensitiveBytesHash<EncodingDB.Entry> encodingdb = EncodingDB.getEncodings();
30 changes: 0 additions & 30 deletions truffle/src/main/java/org/jruby/truffle/aot/substitutions.json
Original file line number Diff line number Diff line change
@@ -19,36 +19,6 @@
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_joda_time_DateTimeUtils",
"originalClass": "org.joda.time.DateTimeUtils",
"methods": [
{
"annotatedName": "getDateFormatSymbols",
"substitute": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_joda_time_tz_ZoneInfoProvider",
"originalClass": "org.joda.time.tz.ZoneInfoProvider",
"methods": [
{
"annotatedName": "getZone",
"substitute": true
},
{
"annotatedName": "openResource",
"substitute": true
}
],
"fields": [
{
"annotatedName": "iFileDir",
"alias": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_truffle_language_loader_SourceLoader",
"originalClass": "org.jruby.truffle.language.loader.SourceLoader",
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@
import jnr.constants.platform.Errno;
import org.jcodings.Encoding;
import org.jcodings.specific.ASCIIEncoding;
import org.joda.time.DateTime;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.encoding.EncodingManager;
import org.jruby.truffle.core.string.ByteList;
@@ -450,11 +449,11 @@ public ByteList formatToByteList(List<Token> compiledPattern, ZonedDateTime dt)
break;
case FORMAT_WEEK_YEAR_M:
type = NUMERIC2;
value = formatWeekYear(dt, Calendar.MONDAY);
value = formatWeekOfYear(dt, Calendar.MONDAY);
break;
case FORMAT_WEEK_YEAR_S:
type = NUMERIC2;
value = formatWeekYear(dt, Calendar.SUNDAY);
value = formatWeekOfYear(dt, Calendar.SUNDAY);
break;
case FORMAT_DAY_WEEK:
type = NUMERIC;
@@ -510,12 +509,12 @@ public ByteList formatToByteList(List<Token> compiledPattern, ZonedDateTime dt)
formatter = RubyTimeOutputFormatter.DEFAULT_FORMATTER; // no more formatting
break;
case FORMAT_WEEKYEAR:
value = new DateTime(dt.toInstant().getEpochSecond() * 1_000).getWeekyear();
value = GregorianCalendar.from(dt).getWeekYear();
type = (value >= 0) ? NUMERIC4 : NUMERIC5;
break;
case FORMAT_WEEKYEAR_SHORT:
value = GregorianCalendar.from(dt).getWeekYear() % 100;
type = NUMERIC2;
value = new DateTime(dt.toInstant().getEpochSecond() * 1_000).getWeekyear() % 100;
break;
case FORMAT_MICROSEC_EPOCH:
// only available for Date
@@ -542,13 +541,13 @@ public ByteList formatToByteList(List<Token> compiledPattern, ZonedDateTime dt)
return toAppendTo;
}

private int formatWeekYear(ZonedDateTime dt, int firstDayOfWeek) {
private int formatWeekOfYear(ZonedDateTime dt, int firstDayOfWeek) {
Calendar dtCalendar = GregorianCalendar.from(dt);
dtCalendar.setFirstDayOfWeek(firstDayOfWeek);
dtCalendar.setMinimalDaysInFirstWeek(7);
int value = dtCalendar.get(Calendar.WEEK_OF_YEAR);
if ((value == 52 || value == 53) &&
(dtCalendar.get(Calendar.MONTH) == Calendar.JANUARY )) {
(dtCalendar.get(Calendar.MONTH) == Calendar.JANUARY)) {
// MRI behavior: Week values are monotonous.
// So, weeks that effectively belong to previous year,
// will get the value of 0, not 52 or 53, as in Java.