public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: daniel szmulewicz <daniel.szmulewicz@gmail.com>
To: kawa@sourceware.org
Subject: java 11
Date: Sun, 02 Dec 2018 23:01:00 -0000	[thread overview]
Message-ID: <CAABPU6-FNdaCyBKCsXq5csy7Gb3casPQQdmNKeK96mF0OAm3WA@mail.gmail.com> (raw)

Hi,

I wrote my first Kawa script, yay!
I wanted to explore Java interop, so the following script does a http
request with the new HttpClient that ships in Java 11. However, as you can
see, some methods needed to be fully qualified in order to make it work. Is
this a case of reflection not working with the new Java modules? Am I
missing something? Thank you!

-- Code below this line
(import (class java.net URI))
(import (class java.net.http HttpClient HttpRequest HttpResponse))

(define uri (URI:create "
http://cr.openjdk.java.net/~chegar/httpclient/02/javadoc/api/java.net.http/java/net/http/HttpClient.html
"))
(define body-handler (HttpResponse:BodyHandlers:ofString))
(define client (*:build (HttpClient:newBuilder)))
(define request (*:build (*:uri (HttpRequest:newBuilder) uri)))
(define response (java.net.http.HttpClient:send client request
body-handler))
(display (java.net.http.HttpResponse:body response))

             reply	other threads:[~2018-12-02 23:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-02 23:01 daniel szmulewicz [this message]
2018-12-03  1:50 ` Per Bothner
2018-12-03  2:49   ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAABPU6-FNdaCyBKCsXq5csy7Gb3casPQQdmNKeK96mF0OAm3WA@mail.gmail.com \
    --to=daniel.szmulewicz@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).