all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#46451] [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts
@ 2021-02-11 23:14 Björn Höfling
  2021-02-11 23:20 ` [bug#46451] [PATCH 1/2] gnu: openjdk@9 : Add phase to hardcode libraries Björn Höfling
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Björn Höfling @ 2021-02-11 23:14 UTC (permalink / raw)
  To: 46451

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

These two patches fix a NullPointerException in the OpenJDK packages.

The patches apply only to OpenJDK9 and OpenJDK11, but with inheritence
all OpenJDKx with x\in[9..14] are covered.

Here is the bug report:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41177

In order to test it you can use the following Main.java:

~~~~~~
import java.awt.*;

public class Main {

    public static void main(String[] args)
    {
        String fonts[] =
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

        for ( int i = 0; i < fonts.length; i++ )
	    {
		System.out.println(fonts[i]);
	    }
    }
}

~~~~~~~~
Compile: javac Main.java
Run: java -cp . Main

It should print a list of the available fonts.


Björn


Björn Höfling (2):
  gnu: openjdk@9 : Add phase to hardcode libraries.
  gnu: openjdk11: Add phase to hardcode libraries.

 gnu/packages/java.scm | 56 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

-- 
2.27.0


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* [bug#46451] [PATCH 1/2] gnu: openjdk@9 : Add phase to hardcode libraries.
  2021-02-11 23:14 [bug#46451] [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Björn Höfling
@ 2021-02-11 23:20 ` Björn Höfling
  2021-02-11 23:20 ` [bug#46451] [PATCH 2/2] gnu: openjdk11: " Björn Höfling
  2021-02-12 10:52 ` bug#41177: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Leo Prikler
  2 siblings, 0 replies; 5+ messages in thread
From: Björn Höfling @ 2021-02-11 23:20 UTC (permalink / raw)
  To: 46451

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

* gnu/packages/java.scm (openjdk9)[arguments]: Add patch-jni-libs phase.

This fixes a NullPointerException related to using fontconfig
reported by Jonathan Frederickson <jonathan@terracrypt.net>
in <https://bugs.gnu.org/41177>.
---
 gnu/packages/java.scm | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index d6afb2e9d3..a63dad8755 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -10,7 +10,7 @@
 ;;; Copyright © 2018, 2019 Gábor Boskovits <boskovits@gmail.com>
 ;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2018, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2019, 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
+;;; Copyright © 2019, 2020, 2021 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
@@ -1928,6 +1928,33 @@ new Date();"))
                                                  (number->string (parallel-job-count))))
                             '())
                       ,@make-flags))))
+         (add-after 'unpack 'patch-jni-libs
+           ;; Hardcode dynamically loaded libraries.
+           (lambda _
+             (let* ((library-path (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH")))
+                    (find-library (lambda (name)
+                                    (search-path
+                                     library-path
+                                     (string-append "lib" name ".so")))))
+               (for-each
+                (lambda (file)
+                  (catch 'decoding-error
+                    (lambda ()
+                      (substitute* file
+                        (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
+                          _ name version)
+                         (format #f "\"~a\""  (find-library name)))
+                        (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
+                         (format #f "\"~a\"" (find-library name)))))
+                    (lambda _
+                      ;; Those are safe to skip.
+                      (format (current-error-port)
+                                      "warning: failed to substitute: ~a~%"
+                                      file))))
+                (find-files "."
+                            "\\.c$|\\.h$"))
+               #t)))
          ;; Some of the libraries in the lib/ folder link to libjvm.so.
          ;; But that shared object is located in the server/ folder, so it
          ;; cannot be found.  This phase creates a symbolic link in the
-- 
2.27.0


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* [bug#46451] [PATCH 2/2] gnu: openjdk11: Add phase to hardcode libraries.
  2021-02-11 23:14 [bug#46451] [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Björn Höfling
  2021-02-11 23:20 ` [bug#46451] [PATCH 1/2] gnu: openjdk@9 : Add phase to hardcode libraries Björn Höfling
@ 2021-02-11 23:20 ` Björn Höfling
  2021-02-12 10:52 ` bug#41177: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Leo Prikler
  2 siblings, 0 replies; 5+ messages in thread
From: Björn Höfling @ 2021-02-11 23:20 UTC (permalink / raw)
  To: 46451

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

* gnu/packages/java.scm (openjdk11)[arguments]: Add patch-jni-libs phase.

    This fixes a NullPointerException related to using fontconfig
    reported by Jonathan Frederickson <jonathan@terracrypt.net>
    in <https://bugs.gnu.org/41177>.
---
 gnu/packages/java.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index a63dad8755..85ca37d8b6 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2139,6 +2139,33 @@ new Date();"))
              (substitute* "make/data/blacklistedcertsconverter/blacklisted.certs.pem"
                (("^#!.*") "#! java BlacklistedCertsConverter SHA-256\n"))
              #t))
+         (add-after 'unpack 'patch-jni-libs
+           ;; Hardcode dynamically loaded libraries.
+           (lambda _
+             (let* ((library-path (search-path-as-string->list
+                                   (getenv "LIBRARY_PATH")))
+                    (find-library (lambda (name)
+                                    (search-path
+                                     library-path
+                                     (string-append "lib" name ".so")))))
+               (for-each
+                (lambda (file)
+                  (catch 'decoding-error
+                    (lambda ()
+                      (substitute* file
+                        (("VERSIONED_JNI_LIB_NAME\\(\"(.*)\", \"(.*)\"\\)"
+                          _ name version)
+                         (format #f "\"~a\""  (find-library name)))
+                        (("JNI_LIB_NAME\\(\"(.*)\"\\)" _ name)
+                         (format #f "\"~a\"" (find-library name)))))
+                    (lambda _
+                      ;; Those are safe to skip.
+                      (format (current-error-port)
+                                      "warning: failed to substitute: ~a~%"
+                                      file))))
+                (find-files "."
+                            "\\.c$|\\.h$"))
+               #t)))
          (add-before 'build 'write-source-revision-file
            (lambda _
              (with-output-to-file ".src-rev"
-- 
2.27.0


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* bug#41177: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts
  2021-02-11 23:14 [bug#46451] [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Björn Höfling
  2021-02-11 23:20 ` [bug#46451] [PATCH 1/2] gnu: openjdk@9 : Add phase to hardcode libraries Björn Höfling
  2021-02-11 23:20 ` [bug#46451] [PATCH 2/2] gnu: openjdk11: " Björn Höfling
@ 2021-02-12 10:52 ` Leo Prikler
  2021-02-12 19:59   ` Björn Höfling
  2 siblings, 1 reply; 5+ messages in thread
From: Leo Prikler @ 2021-02-12 10:52 UTC (permalink / raw)
  To: Björn Höfling; +Cc: 46451-done, 41177-done

Hi Björn

Am Freitag, den 12.02.2021, 00:14 +0100 schrieb Björn Höfling:
> These two patches fix a NullPointerException in the OpenJDK packages.
> 
> The patches apply only to OpenJDK9 and OpenJDK11, but with
> inheritence
> all OpenJDKx with x\in[9..14] are covered.
> 
> Here is the bug report:
> 
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41177
> 
> In order to test it you can use the following Main.java:
> 
> ~~~~~~
> import java.awt.*;
> 
> public class Main {
> 
>     public static void main(String[] args)
>     {
>         String fonts[] =
>             GraphicsEnvironment.getLocalGraphicsEnvironment().getAvai
> lableFontFamilyNames();
> 
>         for ( int i = 0; i < fonts.length; i++ )
> 	    {
> 		System.out.println(fonts[i]);
> 	    }
>     }
> }
> 
> ~~~~~~~~
> Compile: javac Main.java
> Run: java -cp . Main
> 
> It should print a list of the available fonts.
Indeed, that it does.  At least for 9 and 11, which I've invoked
directly from their store paths.

I've pushed your patches with small changes to the commit messages and
followed up with an indentation fix.

Regards,
Leo





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

* bug#41177: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts
  2021-02-12 10:52 ` bug#41177: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Leo Prikler
@ 2021-02-12 19:59   ` Björn Höfling
  0 siblings, 0 replies; 5+ messages in thread
From: Björn Höfling @ 2021-02-12 19:59 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 46451-done, 41177-done

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

On Fri, 12 Feb 2021 11:52:50 +0100
Leo Prikler <leo.prikler@student.tugraz.at> wrote:

> I've pushed your patches with small changes to the commit messages and
> followed up with an indentation fix.

Thanks! 

Björn


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2021-02-12 20:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-11 23:14 [bug#46451] [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Björn Höfling
2021-02-11 23:20 ` [bug#46451] [PATCH 1/2] gnu: openjdk@9 : Add phase to hardcode libraries Björn Höfling
2021-02-11 23:20 ` [bug#46451] [PATCH 2/2] gnu: openjdk11: " Björn Höfling
2021-02-12 10:52 ` bug#41177: [PATCH 0/2] OpenJDK: Fix NullPointerException when accessing fonts Leo Prikler
2021-02-12 19:59   ` Björn Höfling

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.