unofficial mirror of guix-patches@gnu.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
  2021-02-11 23:20 ` [bug#46451] [PATCH 2/2] gnu: openjdk11: " Björn Höfling
  0 siblings, 2 replies; 3+ 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] 3+ 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
  1 sibling, 0 replies; 3+ 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] 3+ 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
  1 sibling, 0 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2021-02-11 23:21 UTC | newest]

Thread overview: 3+ 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

Code repositories for project(s) associated with this public inbox

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

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