United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7120895 FontConfiguration should not use thread contextClassLoader
7120895 : FontConfiguration should not use thread contextClassLoader

Details
Type:
Bug
Submit Date:
2011-12-13
Status:
Closed
Updated Date:
2012-07-18
Project Name:
JDK
Resolved Date:
2012-07-18
Component:
client-libs
OS:
generic,windows_xp,windows_7
Sub-Component:
2d
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7,8
Fixed Versions:
7u6

Related Reports
Backport:
Duplicate:
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
Env: 
winxp, jre8 pit bundle:  http://rehudson.us.oracle.com:8080/hudson/job/jdk8_deploy-1-prebuild/ws/bundles/windows-i586/b255-2011-12-09_92/
rdp of testing machine:  leexlee.cn.oracle.com  duke/hello

When launching a javaws app, sometimes, the app can't be launched, no window showed up, but the process still there.
like 
http://nicole1.us.oracle.com:8080/JavawsMustangIntegTest/custom_progress/custom_progress_signed_different.jnlp

Please see the attached jstack log

                                    

Comments
SUGGESTED FIX

http://cr.openjdk.java.net/~bae/7120895/7u6/webrev.00/
                                     
2012-05-31
EVALUATION

Custom progress bar is implemented in Swing and to be able to show it Swing need to be initialized.

This assumes FontConfiguration object is initialized and it has following code in it:

=========
    private CharsetEncoder getFontCharsetEncoder(final String charsetName,
            String fontName) {

        Charset fc = null;
        if (charsetName.equals("default")) {
            fc = (Charset) charsetRegistry.get(fontName);
        } else {
            fc = (Charset) charsetRegistry.get(charsetName);
        }
        if (fc != null) {
            return fc.newEncoder();
        }

        if (!charsetName.startsWith("sun.awt.") && !charsetName.equals("default")) {
            fc = Charset.forName(charsetName);
        } else {
            Class fcc = (Class) AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        try {
                            return Class.forName(charsetName, true,
                                                 Thread.currentThread().getContextClassLoader());
                        } catch (ClassNotFoundException e) {
                        }
                        return null;
                    }
                });
==========

On this system we end up in the last block and trying to use jnlp classloader to lookup some missing class.

Based on WFontConfiguration.getEncoding() it likely be one of 
        subsetEncodingMap.put("chinese-hkscs", "sun.awt.HKSCS");
        subsetEncodingMap.put("dingbats", "sun.awt.windows.WingDings");
        subsetEncodingMap.put("symbol", "sun.awt.Symbol");

Note that charset name we trying to resolve comes from one of the fonts installed on the system.
I.e. if system has such font then performance for web apps using lazy jars may be really bad.
Given that test system has launguage set to Chinese (PRC) i'd guess font has "chinese-hkscs" encoding but not 100% sure.

Anyway, lookup of misisng class on JNLP classloader will cause ALL jars to be loaded and nothing will be visible on the screen 
because we are still initializing 2d/Swing. It seem to be 2D issue and need to be resolved in 2D code.

It seem that:
   a) Thread.currentThread().getContextClassLoader() should not be used there
   b) encoding handling need to be improved (does it mean we do not have correct charset support in JRE for one of chinese encodings?
        seem unlikely => problem should be in the mapping code?)

Transferring to 2D team for evaluation.
                                     
2012-01-10
EVALUATION

when I launch this tese:

http://nicole1.us.oracle.com:8080/JavawsMustangIntegTest/custom_progress/custom_progress_signed_different.jnlp

I always get error dialog:

#### Java Web Start Error
#### JAR resources in JNLP file are not signed by same certificate

this test case works always:   http://nicole1.us.oracle.com:8080/JavawsMustangIntegTest/custom_progress/custom_progress_helper_lazy.jnlp
(but I don't see any progress dialog)

this testcase works too:  http://nicole1.us.oracle.com:8080/JavawsMustangIntegTest/custom_progress/custom_progress_signed.jnlp
(I see custom progress, and the custom progress dialog did not get dismissed after application window is shown.)

But I cannot get any process to stuck/hang so far.
                                     
2011-12-19



Hardware and Software, Engineered to Work Together