From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9038 invoked by alias); 3 Dec 2018 01:50:05 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 8517 invoked by uid 89); 3 Dec 2018 01:50:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00,KAM_NUMSUBJECT,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*kawa, evaluates, explore, undesirable X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Dec 2018 01:50:02 +0000 Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1gTdMw-0004tq-3E; Mon, 03 Dec 2018 02:49:54 +0100 Received: by mailfront12.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1gTdMZ-0004t3-QM; Mon, 03 Dec 2018 02:49:32 +0100 Subject: Re: java 11 To: daniel szmulewicz , kawa@sourceware.org References: From: Per Bothner Message-ID: Date: Mon, 03 Dec 2018 01:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-q4/txt/msg00032.txt.bz2 On 12/2/18 3:00 PM, daniel szmulewicz wrote: > 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! Works for me (using openjdk 11.0.1). Your problem may be that you're running the script using load, or using the -f command-line flag. That reads, compiles, and evaluates each line one-by-one which is undesirable for a number of reasons. For one it hurts various optimizations and requires more reflection. Instead run the script directly from the command line: $ kawa my-script.scm (without using the -f option). If using the REPL, you can use require instead of load: $ kawa #|kawa:3|# (require "my-script.scm") Note that "load" is a procedure that reads the file line-by-line, while "require" is syntax (a macro) that reads the file at "compile-time". It will also work better (no warnings) if you stick to using the CLASS_NAME:METHOD_NAME syntax for static methods. For instance methods we prefer INSTANCE:METHOD_NAME. Specifically, replace the last two lines by: (define response (client:send request body-handler)) (display (response:body)) -- --Per Bothner per@bothner.com http://per.bothner.com/