public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Re: Building for Android
       [not found] <CAMFYt2a2uJQGyDQ3a_6d_KxFd=k4CHh_q5SQoY5yyCW=ztJJQg@mail.gmail.com>
@ 2022-10-18 15:25 ` Per Bothner
       [not found]   ` <CAMFYt2bzaVLJi8JNJGJ2aOv6FbhvS7YoFBo5zdUCccEJKJRSVw@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2022-10-18 15:25 UTC (permalink / raw)
  To: Panicz Maciej Godek, kawa



On 10/18/22 07:57, Panicz Maciej Godek via Kawa wrote:
> PARSE ERROR:
>   unsupported class file version 61.0
> ...while parsing gnu/bytecode/Access.class
> 
> So, what I suppose happens, is that the javac which builds Kawa emits byte
> code that is unsupported by dx.

Try specifying the --release to javac. This may be helpful:
https://stackoverflow.com/questions/43102787/what-is-the-release-flag-in-the-java-9-compiler

> I tried building Kawa having passed --with-java-source=7 to the 'configure'
> script, but that didn't help.

Yes, IIRC (if I recall correctly) that doesn't change teh options passed to javac.

You can pass the --target option to the kawa command when compiling Scheme to class files,
but that currently defaults to 52 (Java 8), which hopefuly dexer will handle.

> I also tried aliasing javac as javac -release 7, but it still seens to
> produce the class file version 61.0.

Hm. That is weird.  You can try an exlicit 'javac --target 8' (say).
According to https://en.wikipedia.org/wiki/Java_version_history
class file version 61.0 is Java 17.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building for Android
       [not found]     ` <CAMFYt2ZOJVxu1M49Y=enFZBX3=9mHMMBcjjDA4thc7VAZUZq5g@mail.gmail.com>
@ 2022-10-19 16:05       ` Per Bothner
       [not found]         ` <CAMFYt2b7ckwgQZs1XVJZaWWa_pVn_fwGB-RFtB-=Hr8zeabFtQ@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2022-10-19 16:05 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: kawa



On 10/19/22 02:15, Panicz Maciej Godek wrote:
> However, even after fixing that, I get another error:
> 
> Error: Field name '\=android\,view\,View' cannot be represented in dex format.
> 
> I really don't know how to overcome that one (IIRC Kawa 1.13 used $Dt as a replacement for a dot)

There is still logic in Kawa to use-old style mangling (such as "$Dt" for ".") when Kawa
is build for Android.  Notice the /* #ifdef Android */ in gnu/expr/Magling.java.

This code is supposed to be enable by the gnu/kawa/util/PreProcess.java helper,
specifically if you configure --with-android.

So the first step is to make sure your working copy of Mangling.java actually does have the USE_SYMBOLIC
set to false.  If it doesn't, delete the file selected-java-source, and re-run configure and make.
Check the PreProcess in the 'make' log.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building for Android
       [not found]         ` <CAMFYt2b7ckwgQZs1XVJZaWWa_pVn_fwGB-RFtB-=Hr8zeabFtQ@mail.gmail.com>
@ 2022-10-21 18:00           ` Per Bothner
       [not found]           ` <CAMFYt2bqUXXa4UbgutPAonBW4dw17ar+nH5EEJUM5JCm6caW=A@mail.gmail.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Per Bothner @ 2022-10-21 18:00 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]



On 10/19/22 10:09, Panicz Maciej Godek wrote:
> So, I did check, and USE_SYMBOLIC is set to true.

Let's fix that first.

> I followed your instruction: I removed selected-java-source, make clean, and then I typed this:
> 
> ./configure --prefix=$HOME/usr --without-awt --without-swt --without-sax2 --without-swing --with-java-source=8 --without-httpserver --disable-xquery --disable-echo2 --disable-jemacs --disable-brl --with-android=/data/data/com.termux/files/usr/share/java/android.jar

I figured it out: The --with-java-source=8 overrides the --with-android flag in terms of PreProcess arguments.

Please try the attached patch. It should force '+Android' as a PreProcess argument.
It seems to work even if you use --with-java-source, in the sense of setting USE_SYMBOLIC to false.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

[-- Attachment #2: mk-patch.txt --]
[-- Type: text/plain, Size: 925 bytes --]

diff --git a/Makefile.am b/Makefile.am
index 062b9b7e7..b77e4d0e3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -368,6 +368,11 @@ endif
 
 JAVA_SOURCE = @JAVA_SOURCE@
 
+if WITH_ANDROID
+PREPROCESS_ANDROID = +Android
+else
+PREPROCESS_ANDROID = -Android
+endif
 if WITH_HTTPSERVER
 PREPROCESS_HTTPSERVER = +use:com.sun.net.httpserver
 else
@@ -405,7 +410,7 @@ kawa/Version.class: kawa/Version.java
 gnu/kawa/util/PreProcess.class: gnu/kawa/util/PreProcess.java
 	$(JAVAC) -d . $(JAVACFLAGS) $^
 
-JAVA_PREPROCESS_OPTIONS = @JAVA_SOURCE_SELECTOR@ $(PREPROCESS_HTTPSERVER) $(PREPROCESS_XML) $(PREPROCESS_JLINE3) $(PREPROCESS_LSP4J) $(PREPROCESS_AWT)
+JAVA_PREPROCESS_OPTIONS = @JAVA_SOURCE_SELECTOR@ $(PREPROCESS_HTTPSERVER) $(PREPROCESS_XML) $(PREPROCESS_JLINE3) $(PREPROCESS_LSP4J) $(PREPROCESS_AWT) $(PREPROCESS_ANDROID)
 
 selected-java-source: Makefile $(srcdir)/patch-source-list
 	if test ! -e selected-java-source -o \

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building for Android
       [not found]                 ` <CAMFYt2aHPDMm2DYOj8HWj92SSRRKooY+G-BSYd-AvSuCbdy6MQ@mail.gmail.com>
@ 2022-10-21 18:11                   ` Per Bothner
       [not found]                     ` <CAMFYt2bukzei_WEzC85rMGxXHU2kci+KC=tLZNH6Q+rA2D7b5A@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2022-10-21 18:11 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: kawa



On 10/21/22 06:59, Panicz Maciej Godek wrote:
> I found out (by analyzing the somewhat messy gnu/kawa/util/PreProcess.java) that the reason why I hand to edit gnu/expr/Mangling.java by hand was that - in addition to --with-android -- I was also using --with-java-source to ./configure.

I didn't see this until I figured it out independently ...

> 
> The jar produced without that flag was able to build the HelloKawa project (provided that I did the trick with injecting --release 8 to javac).
> 
> However, the d8 tool still issues its warnings, and the member field names containing 'mangled' characters are still invisible from the subclasses.
> 
> While this isn't something I can't live with - because I don't have that many such use cases - I wanted to ask about the chances of resolving that issue?

Well, if the fix in my previous sets USE_SYMBOLIC to false for you,
the part of the problem is solved.

If you're still getting invalidly mangled field names, we should figure out why.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building for Android
       [not found]                     ` <CAMFYt2bukzei_WEzC85rMGxXHU2kci+KC=tLZNH6Q+rA2D7b5A@mail.gmail.com>
@ 2022-10-21 19:31                       ` Per Bothner
       [not found]                         ` <CAMFYt2Y3gU9ZZrLYbNYF_3Ad9TyMzuRE7ZaqMZrwC8TXpsO6nQ@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2022-10-21 19:31 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: kawa



On 10/21/22 12:19, Panicz Maciej Godek wrote:

> However, the issue with accessing superclass properties with mangled names from a subclass remains unsolved.

Can you come up with a test-case that doesn't require Android,
but fails if you force USE_SYMBOLIC to force?  Comment out the /* #ifdef */ etc.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building for Android
       [not found]                         ` <CAMFYt2Y3gU9ZZrLYbNYF_3Ad9TyMzuRE7ZaqMZrwC8TXpsO6nQ@mail.gmail.com>
@ 2022-10-22  6:26                           ` Per Bothner
       [not found]                             ` <CAMFYt2ZycvzvhbFyh6M6Gy6Svrzdiu5CSL_0Kc+qskvUy5Nkmw@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Per Bothner @ 2022-10-22  6:26 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]



On 10/21/22 12:45, Panicz Maciej Godek wrote:
> During its compilation, Kawa issues the following warning:
> 
> subclass-refering-to-mangled-superclass-property.scm:6:4: warning - no declaration seen for mangled-name

The attached patch seems to fix it.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

[-- Attachment #2: tr-diff.txt --]
[-- Type: text/plain, Size: 823 bytes --]

diff --git a/kawa/lang/Translator.java b/kawa/lang/Translator.java
index d01e83618..745b23d78 100644
--- a/kawa/lang/Translator.java
+++ b/kawa/lang/Translator.java
@@ -877,9 +877,8 @@ public class Translator extends Compilation
                     } else {
                         gnu.expr.SourceName snameAnn =
                             part.getAnnotation(gnu.expr.SourceName.class);
-                        String pname = snameAnn == null ? part.getName()
-                            : snameAnn.name();
-                        if (! dname.equals(pname))
+                        // If SourceName annotation, require exact match.
+                        if (snameAnn != null && ! dname.equals(snameAnn.name()))
                             continue;
                     }
                     Expression part1;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building for Android
       [not found]                                 ` <CAMFYt2ZfYSKSvdUvnxR-BN2POygvwPbRhmFF2o0D_AoHH0BhUw@mail.gmail.com>
@ 2022-10-24 10:48                                   ` Per Bothner
  0 siblings, 0 replies; 7+ messages in thread
From: Per Bothner @ 2022-10-24 10:48 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: kawa



On 10/24/22 00:22, Panicz Maciej Godek wrote:
> I've noticed that, in my code, I've been using the names "hash-code" and "java.lang.System:identity-hash-code".

I think it is best to use Java names (such as identityHashCode) for things that come from Java.
(I haven't always been consistent about that.)

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-24 10:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAMFYt2a2uJQGyDQ3a_6d_KxFd=k4CHh_q5SQoY5yyCW=ztJJQg@mail.gmail.com>
2022-10-18 15:25 ` Building for Android Per Bothner
     [not found]   ` <CAMFYt2bzaVLJi8JNJGJ2aOv6FbhvS7YoFBo5zdUCccEJKJRSVw@mail.gmail.com>
     [not found]     ` <CAMFYt2ZOJVxu1M49Y=enFZBX3=9mHMMBcjjDA4thc7VAZUZq5g@mail.gmail.com>
2022-10-19 16:05       ` Per Bothner
     [not found]         ` <CAMFYt2b7ckwgQZs1XVJZaWWa_pVn_fwGB-RFtB-=Hr8zeabFtQ@mail.gmail.com>
2022-10-21 18:00           ` Per Bothner
     [not found]           ` <CAMFYt2bqUXXa4UbgutPAonBW4dw17ar+nH5EEJUM5JCm6caW=A@mail.gmail.com>
     [not found]             ` <CAMFYt2Z29eaiJgh-Oms2ieouQsYeG9GfPz6pvj_vmAEVvXcCtQ@mail.gmail.com>
     [not found]               ` <CAMFYt2Z8moCDk7GNTu_zHPRaw=BB+7BdS+fF965FkaiZvLx8oA@mail.gmail.com>
     [not found]                 ` <CAMFYt2aHPDMm2DYOj8HWj92SSRRKooY+G-BSYd-AvSuCbdy6MQ@mail.gmail.com>
2022-10-21 18:11                   ` Per Bothner
     [not found]                     ` <CAMFYt2bukzei_WEzC85rMGxXHU2kci+KC=tLZNH6Q+rA2D7b5A@mail.gmail.com>
2022-10-21 19:31                       ` Per Bothner
     [not found]                         ` <CAMFYt2Y3gU9ZZrLYbNYF_3Ad9TyMzuRE7ZaqMZrwC8TXpsO6nQ@mail.gmail.com>
2022-10-22  6:26                           ` Per Bothner
     [not found]                             ` <CAMFYt2ZycvzvhbFyh6M6Gy6Svrzdiu5CSL_0Kc+qskvUy5Nkmw@mail.gmail.com>
     [not found]                               ` <CAMFYt2b5Yw10wfzm6xWbwFni_u0HqpcnSFuCAgSFDLZ=XCd47Q@mail.gmail.com>
     [not found]                                 ` <CAMFYt2ZfYSKSvdUvnxR-BN2POygvwPbRhmFF2o0D_AoHH0BhUw@mail.gmail.com>
2022-10-24 10:48                                   ` Per Bothner

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).