JDK-4408438 : (cs) Strings with German characters will not compile on Merlin-beta build 49
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_7
  • CPU: generic,sparc
  • Submitted: 2001-01-26
  • Updated: 2001-07-19
  • Resolved: 2001-07-19
Related Reports
Duplicate :  
Description
Strings with German characters will not compile on Merlin-beta build 49 
The test case (below) compiles fine with 1.2 and 1.3, but not with 1.4.  
(It also compiles fine with Ladybird build 14.)

echawkes@gradgrind:/home/echawkes/tests/4320834( 101 )% /usr/local/java/jdk1.2/solaris/bin/javac *.java
echawkes@gradgrind:/home/echawkes/tests/4320834( 103 )% /usr/local/java/jdk1.4/solsparc/bin/javac *.java
JFrame1.java:28: unclosed string literal
                setTitle("???; //<<<<<<<<<< not supported !!!!!!!!!!!
                         ^
JFrame1.java:30: ')' expected
                setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
                                                                                ^

Test case (taken from 4320834) : 
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JFrame1 extends javax.swing.JFrame
{
	public JFrame1()
	{
		super();
		setTitle("��, ��, ��"); //<<<<<<<<<< not supported !!!!!!!!!!!
		
setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout(0,0));
		setSize(488,309);
		setVisible(false);
		JButton1.setText("k");
		getContentPane().add(JButton1);
		JButton1.setFont(new Font("Dialog", Font.PLAIN, 12));
		JButton1.setBounds(0,0,488,309);

		SymWindow aSymWindow = new SymWindow();
		this.addWindowListener(aSymWindow);
	}

	static public void main(String args[])
	{
		try {
			(new JFrame1()).setVisible(true);
		}
		catch (Throwable t) {
			t.printStackTrace();
			//Ensure the application exits with an error condition.
			System.exit(1);
		}
	}

	public void addNotify()
	{
		// Record the size of the window prior to calling parents
addNotify.
		Dimension size = getSize();
		
		super.addNotify();
		
		if (frameSizeAdjusted)
			return;
		frameSizeAdjusted = true;
		
		// Adjust size of frame according to the insets and menu bar
		javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar();
		int menuBarHeight = 0;
		if (menuBar != null)
		    menuBarHeight = menuBar.getPreferredSize().height;
		Insets insets = getInsets();
		setSize(insets.left + insets.right + size.width, insets.top +
insets.bottom + size.height + menuBarHeight);
	}

	// Used by addNotify
	boolean frameSizeAdjusted = false;

	javax.swing.JButton JButton1 = new javax.swing.JButton();

	void exitApplication()
	{
		try {
	    	// Beep
	    	Toolkit.getDefaultToolkit().beep();
	    	// Show a confirmation dialog
	    	int reply = JOptionPane.showConfirmDialog(this,
	    	                                          "Do you really want to
exit?",
	    	                                          "JFC Application -
Exit" ,
	    	                                          
JOptionPane.YES_NO_OPTION,
	    	                                          
JOptionPane.QUESTION_MESSAGE);
			// If the confirmation was affirmative, handle exiting.
			if (reply == JOptionPane.YES_OPTION)
			{
		    	this.setVisible(false);    // hide the Frame
		    	this.dispose();            // free the system resources
		    	System.exit(0);            // close the application
			}
		} catch (Exception e) {
		}
	}

	class SymWindow extends java.awt.event.WindowAdapter
	{
		public void windowClosing(java.awt.event.WindowEvent event)
		{
			Object object = event.getSource();
			if (object == JFrame1.this)
				JFrame1_windowClosing(event);
		}
	}

	void JFrame1_windowClosing(java.awt.event.WindowEvent event)
	{
		// to do: code goes here.
			 
		JFrame1_windowClosing_Interaction1(event);
	}

	void JFrame1_windowClosing_Interaction1(java.awt.event.WindowEvent
event) {
		try {
			this.exitApplication();
		} catch (Exception e) {
		}
	}
}

Comments
PUBLIC COMMENTS .
10-06-2004

EVALUATION This is a side-effect of an overhaul of the java IO implementation upon which the javac compiler rests, not a change in the compiler per se. The compiler was not correct to accept such source code before, as these are not representable in the default encoding of US-ASCII. In fact, the 1.3 compiler silently accepted these characters and converted them to "?", which I'm sure is not what you wanted. You will need to tell the compiler what encoding to use for non-ASCII source characters. See http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc for a synopsis of character encodings. You probably want to use the environment variables unset LC_ALL export LC_CTYPE=iso_8859_1 or possibly the -source compiler flag. Admittedly, the diagnostics could be much, much better. I'm reclassifying this as a java/classes_nio bug, as the behavior of the underlying I/O classes has changed. neal.gafter@Eng 2001-01-25 Probable duplicate of 4403272. The obvious compatibility problem here should be fixed, but to compile with "international strings" you should set the locale as noted above. -- mr@eng 2001/1/26 Rather than the -source compiler flag, I think the -encoding compiler flag was meant, as in /usr/local/java/jdk1.4/solsparc/bin/javac -encoding iso-8859-1 *.java eric.hawkes@eng 2001-01-27 Here's a minimal test that displays the problem, assuming that you do not use the -encoding compiler flag: public class Unmappable { String s = "��, ��, ��"; } $ jdk14; javac Unmappable.java Unmappable.java:2: unclosed string literal String s = "??? ^ Unmappable.java:2: ';' expected String s = "??? ^ 2 errors The problem is that the String s contains characters which are unmappable in the default machine encoding. We would expect a substitution to occur for each unmappable character and the '"' should be detected. Unfortunately, the submitter is encountering bug 4457851. After an unmappable character, at least one character is skipped. Note that we would have expected the ", " after the �� and �� to appear but they're missing. The following errors are what we'd expect if the bug in the program existed and we were properly processing unmappable characters. $ jdk13; javac -encoding 8859_1 Unmappable.java Unmappable.java:2: unclosed string literal String s = "?, ?, ? ^ Unmappable.java:2: ';' expected String s = "?, ?, ? ^ 2 errors Closing as duplicate of 4457851. iag@eng 2001-07-19
19-07-2001