Skip to content

Commit 990e491

Browse files
committed
[GR-29813] Fix native-image build on JDK16.
PullRequest: fastr/2580
2 parents 987a324 + 5cd4868 commit 990e491

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/Download.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 1995, 1996 Robert Gentleman and Ross Ihaka
33
* Copyright (c) 1997-2013, The R Core Team
4-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates
4+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@
4848
import com.oracle.truffle.r.runtime.context.RContext;
4949
import com.oracle.truffle.r.runtime.context.TruffleRLanguage;
5050
import java.io.OutputStream;
51-
import sun.net.www.protocol.ftp.FtpURLConnection;
51+
import java.util.Locale;
5252

5353
/**
5454
* Support for the "internal"method of "utils::download.file". TODO take note of "quiet", "mode" and
@@ -72,11 +72,14 @@ public abstract class Download extends RExternalBuiltinNode.Arg6 {
7272
protected int download(String urlString, String destFile, boolean quiet, @SuppressWarnings("unused") String mode, @SuppressWarnings("unused") boolean cacheOK,
7373
@SuppressWarnings("unused") Object headers,
7474
@CachedContext(TruffleRLanguage.class) TruffleLanguage.ContextReference<RContext> ctxRef) {
75+
String protocol;
7576
try {
7677
String urlStr = urlString;
7778
URLConnection con;
7879
while (true) {
79-
con = new URL(urlStr).openConnection();
80+
URL url = new URL(urlStr);
81+
protocol = url.getProtocol();
82+
con = url.openConnection();
8083
if (con instanceof HttpURLConnection) {
8184
HttpURLConnection httpCon = (HttpURLConnection) con;
8285
httpCon.setInstanceFollowRedirects(false);
@@ -124,7 +127,7 @@ protected int download(String urlString, String destFile, boolean quiet, @Suppre
124127
StdConnections.getStderr().writeString(" length unknown", true);
125128
}
126129
StdConnections.getStderr().flush();
127-
} else if (con instanceof FtpURLConnection) {
130+
} else if (protocol != null && protocol.toLowerCase(Locale.ROOT).equals("ftp")) {
128131
if (len >= 0) {
129132
StdConnections.getStderr().writeString(String.format(" ftp data connection made, file length %d bytes", len), true);
130133
} else {

mx.fastr/native-image.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ JavaArgs = \
77
-Dfastr.resource.factory.class=com.oracle.truffle.r.nodes.builtin.EagerResourceHandlerFactory \
88
-Dfastr.internal.usemxbeans=false \
99
-Dfastr.internal.usenativeeventloop=false \
10-
-Dfastr.internal.defaultdownloadmethod=wget \
1110
-Dfastr.internal.ignorejvmargs=true \
1211
-Dfastr.use.remote.grid.awt.device=true \
1312
-Dfastr.awt.support=false \
@@ -16,7 +15,7 @@ JavaArgs = \
1615
Args = -H:MaxRuntimeCompileMethods=20000 \
1716
-H:-TruffleCheckFrameImplementation \
1817
-H:+TruffleCheckBlackListedMethods \
19-
-H:EnableURLProtocols=http \
18+
-H:EnableURLProtocols=http,ftp,https \
2019
-H:-UseServiceLoaderFeature \
2120
--initialize-at-run-time="sun.awt.dnd.SunDropTargetContextPeer\$EventDispatcher,sun.font.FreetypeFontScaler"
2221

0 commit comments

Comments
 (0)