Hi Mario and Dalibor,

Thanks for you feedback. Let me give more information to reproduce it.


1. Get OpenJDK 1.8 code from http://download.java.net/openjdk/jdk8/


[root@localhost rong]# ls -l openjdk-8-src-b132-03_mar_2014.zip
-rwxr--r-- 1 root root 124099402 5月   9 15:34 openjdk-8-src-b132-03_mar_2014.zip



2. Build OpenJDK 1.8, and my build OS is CentOS 6.6, 


[root@localhost rong]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[root@localhost rong]# uname -a
Linux localhost.localdomain 2.6.32-504.el6.i686 #1 SMP Wed Oct 15 03:02:07 UTC 
2014 i686 i686 i386 GNU/Linux



and we will get j2re-image and j2sdk-image folder
[root@localhost rong]# ls 
openjdk/build/linux-x86-normal-server-release/images/j2*
openjdk/build/linux-x86-normal-server-release/images/j2re-image:
ASSEMBLY_EXCEPTION  bin  lib  LICENSE  man  release  THIRD_PARTY_README


openjdk/build/linux-x86-normal-server-release/images/j2sdk-image:
ASSEMBLY_EXCEPTION  bin  demo  include  jre  lib  LICENSE  man  release  sample 
 src.zip  THIRD_PARTY_README



Yes, you are right, now there is no fonts folder in jre/lib.


[root@localhost openjdk]# 
build/linux-x86-normal-server-release/images/j2re-image/bin/java -version
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-root_2016_05_09_10_59-b00)
OpenJDK Server VM (build 25.0-b70, mixed mode)
[root@localhost openjdk]# 
build/linux-x86-normal-server-release/images/j2sdk-image/bin/java -version
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-root_2016_05_09_10_59-b00)
OpenJDK Server VM (build 25.0-b70, mixed mode)



3. Packge j2re-image folder and copied to another Cent OS, this is simple Cent 
OS installation and without any font files. Suppose naming the jre folder 
"javaJRE"


Another CentOS machine information:
[root@va91 UI]# uname -a
Linux va91.openjre 2.6.32-573.3.1.el6.x86_64 #1 SMP Thu Aug 13 22:55:16 UTC 
2015 x86_64 x86_64 x86_64 GNU/Linux



JRE Infomation:
[root@va91 UI]# ls javaJRE
ASSEMBLY_EXCEPTION  bin  lib  LICENSE  man  release  THIRD_PARTY_README
[root@va91 UI]# javaJRE/bin/java -version
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-root_2016_05_09_10_59-b00)
OpenJDK Server VM (build 25.0-b70, mixed mode)



4. Actually most Java codes runs well in this jre environment, but following 
codes (actually 3rd line) will cause NullPointer exception.  


                BufferedImage image = new BufferedImage(200, 200, 
BufferedImage.TYPE_INT_RGB);
                Graphics2D g2 = image.createGraphics();
                FontMetrics fm = g2.getFontMetrics();



Some articles said that's because OpenJRE depends on font files, so I copied 
some font files, and there are two ways:


1) copied font files into /usr/share/fonts folder, that's good and easy, and 
exception vanishes and app runs well.
2) By referring to oracle JRE, I copied font files into openjre/lib/fonts 
folder, and wrote fontconfig.properties. I'm not sure if OpenJRE will parse it 
but it's worty trying. 
[root@va91 javaJRE]# ls lib/font*
lib/fontconfig.properties  lib/fontconfig.properties.src  
lib/fontconfig.RedHat.6.properties.src


lib/fonts:
fonts.dir                 LucidaBrightDemiItalic.ttf  LucidaBrightRegular.ttf  
LucidaSansRegular.ttf     LucidaTypewriterRegular.ttf
LucidaBrightDemiBold.ttf  LucidaBrightItalic.ttf      LucidaSansDemiBold.ttf   
LucidaTypewriterBold.ttf


The expecption still disappeared, but FontMetrics fm has some odd values and 
cause subsequent codes wrong. After further study, I found even I removed all 
fontconfig* files this problem still existed. That means as long as 
jre/lib/fonts folder has font files FontMetrics will have wrong value.


I don't understand why openjre has this behavior and hope to get answer here. 
Will OpenJRE read fontconfig.properties and read font from jre/lib/fonts?
Thanks for you patience and time. 


Regards,
Rong


------------------ 原始邮件 ------------------
发件人: "Mario Torre";<neugens.limasoftw...@gmail.com>;
发送时间: 2016年5月20日(星期五) 晚上10:24
收件人: ""<31731...@qq.com>; 
抄送: "dalibor topic"<dalibor.to...@oracle.com>; 
"awt-dev"<awt-dev@openjdk.java.net>; 
主题: Re: <AWT Dev> An issue of OpenJRE



It's very difficult to understand your issue, beside, it seems that you are 
manually copying around libraries and it's clear that this only has the effect 
of destabilizing the platform.


I suggest to start with a clear description of what the problem is, what is the 
expected behavior, what is the environment and how to reproduce it, in a 
simple, possibly self contained way.


Then you should file a bug report.
Cheers,
Mario

On Friday, 20 May 2016, 31731705 <31731...@qq.com> wrote:
Hi Dalibor,


Actually this time I download OpenJDK source code and build it myself, but I 
still met this issue. I wonder why font files in jre/lib/fonts folder impact 
openjre.


Here is a brief of this problem, I try to decribe it clearly.


I build OpenJDK, and copy j2re-image to my folder such as /home/rong/jre, and 
use this jre to run my java applicaton. In further study I have found following 
codes, fm will have wrong value as long as jre/lib/fonts has font files (some 
ttf files).


                BufferedImage image = new BufferedImage(200, 200, 
BufferedImage.TYPE_INT_RGB);
                Graphics2D g2 = image.createGraphics();
                FontMetrics fm = g2.getFontMetrics();


But if I moved these font files into /usr/share/fonts folder, the problems goes 
away. I'm not sure why these font files impact open jre run time.
I don't think this problem is related to centos.


BTW, I have installed freetype and fontconfig package.



Regards,
Rong





------------------ Original ------------------
From:  "dalibor topic";<dalibor.to...@oracle.com>;
Date:  Fri, May 20, 2016 08:33 PM
To:  "awt-dev"<awt-dev@openjdk.java.net>; 

Subject:  Re: <AWT Dev> An issue of OpenJRE



On 20.05.2016 10:45, 31731705 wrote:
>
> Can someboday tell me the differences

If you have encountered problems with binaries provided by CentOS, 
you'll need to contact CentOS for support.

cheers,
dalibor topic
-- 
<http://www.oracle.com> Dalibor Topic | Principal Product Manager
Phone: +494089091214 <tel:+494089091214> | Mobile: +491737185961
<tel:+491737185961>

ORACLE Deutschland B.V. & Co. KG | Kühnehöfe 5 | 22761 Hamburg

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Jan Schultheiss, Val Maher

<http://www.oracle.com/commitment> Oracle is committed to developing
practices and products that help protect the environment




-- 
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

Java Champion - Blog: http://neugens.wordpress.com - Twitter: @neugens
Proud GNU Classpath developer: http://www.classpath.org/
OpenJDK: http://openjdk.java.net/projects/caciocavallo/

Please, support open standards:
http://endsoftpatents.org/

Reply via email to