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

SynthParser handles relative URIs incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • None
    • 6
    • client-libs
    • Fix Understood
    • x86
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.6.0-beta2-b77, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux localhost.localdomain 2.4.20-31.9 #1 Tue Apr 13 18:04:23 EDT 2004 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      In writing the XML file for a Synth description one can insert external references in a DOCTYPE declaration. According to the XML standard "relative URIs are relative to the location of the resource within which the entity declaration occurs." In other words, in a file theme.xml, any relative references are to be interpreted relative to the location of theme.xml. However, when using Synth, relative references are instead interpreted relative to the location from where the program is run.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a subdirectory 'xml' to your current directory.
      Create a file xml/theme.xml which contains the declaration:

      <!DOCTYPE java [
        <!ENTITY Globals SYSTEM "Globals.xml">
        <!ENTITY Locals SYSTEM "Locals.xml">
        <!ENTITY Specifics SYSTEM "Specifics.xml">
      ]>

      and the references:
      &Globals;
      &Locals;
      &Specifics;

      Add files Globals.xml, Locals.xml, Specifics.xml to the xml directory.

      Write a program which loads the theme file with:
              laf.load(BugDemo.class.getResourceAsStream("xml/theme.xml"), BugDemo.class);

      Run this program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The expected behaviour is that the files xml/Globals.xml, xml/Locals.xml and xml/Specifics.xml are included in xml/theme.xml and processed.
      ACTUAL -
      Instead, the parser fails to find the files.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The program included below, when run in the directory /home/kai/, and with an XML file as indicated above, will fail with:

      Parsing of xml/theme.xml failed with Error parsing: java.io.FileNotFoundException: /home/kai/Globals.xml (No such file or directory)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import java.text.*;
      import java.util.*;
      import javax.swing.*;
      import javax.swing.border.*;
      import javax.swing.plaf.synth.*;

      public class BugDemo {

        private static final String lafFileName = "xml/theme.xml";

        public BugDemo() {
            SynthLookAndFeel laf = new SynthLookAndFeel();
            try {
              laf.load(BugDemo.class.getResourceAsStream(lafFileName), BugDemo.class);
            } catch (ParseException e) {
              System.err.println("Parsing of " + lafFileName + " failed with " + e.getMessage());
            }
            try {
              UIManager.setLookAndFeel(laf);
            } catch (UnsupportedLookAndFeelException e) {
              System.err.println("Look and Feel setting failed with " + e.getMessage());
            }

        }

        public static void main(String args[]) {
          BugDemo test = new BugDemo();
        }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The current workaround is that the path relative to the run directory has to be given in the master file theme.xml, but this is clearly very inconvenient as it requires modifying the file every time its directory is renamed or moved or the program is run from a different directory.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: