Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6785354

REG: getFontMetrics throws AccessControlException with unsigned applet in 6u11

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6u11
    • deploy
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_11"
      Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
      Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP SP3

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Internet Explorer 7.0.5730.11CO

      A DESCRIPTION OF THE PROBLEM :
      When an unsigned applet try to call Font.getFontMetrics, Java 6 Update 11 will throws an AccessControlException trying to read c:\windows\fonts\arial.ttf directory.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Compile the applet test case
      2) Run it using Java Plug-in 6u11

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The AccessControlException should not occur and the applet display "Hello World"
      ACTUAL -
      An exception occurs and the applet displays nothing

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-11" java.security.AccessControlException: access denied (java.io.FilePermission C:\WINDOWS\Fonts\ARIAL.TTF read)
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
      at java.security.AccessController.checkPermission(AccessController.java:546)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
      at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
      at java.io.File.exists(File.java:731)
      at sun.font.FontManager.getPathName(FontManager.java:1502)
      at sun.font.FontManager.findFontFromPlatform(FontManager.java:1587)
      at sun.font.FontManager.findFont2D(FontManager.java:1788)
      at java.awt.Font.getFont2D(Font.java:452)
      at sun.font.FontManager.getFont2D(Native Method)
      at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:343)
      at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:336)
      at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:284)
      at sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:764)
      at FontMetricsApplet.paint(FontMetricsApplet.java:16)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
      at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
      at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Color;
      import java.awt.Font;
      import java.awt.FontMetrics;
      import java.awt.Graphics;

      import javax.swing.JApplet;


      public class FontMetricsApplet extends JApplet {

      @Override
      public void paint(Graphics g) {
      Font font = new Font("Arial", Font.BOLD, 30);
      g.setFont(font);

      FontMetrics fm = g.getFontMetrics();
      g.setColor(Color.BLACK);

      int y = fm.getHeight();
      g.drawString("Hello World", 10, y);
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Sign the applet and grant all permission.

      Release Regression From : 6
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            Unassigned Unassigned
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: