JTextComponent paste exception

Michael Hall mik3hall at gmail.com
Fri Dec 14 17:50:39 PST 2012


On Dec 13, 2012, at 4:29 AM, Michael Hall wrote:

> On Dec 12, 2012, at 8:40 PM, Roger Lewis wrote:
> 
>> Hi Michael,
>> 
>> Can you first try with 7u10? DataTransferer.java handles of some encoding and there were a number of bugs fixed since 7u7 that could resolve the issue being seen.
>> For example: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7193966
>> 
>> For convince:
>> http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
> 
> Roger,
> I was just going  to file the bug report.
> The problem appears to be an incorrect path to the jdk flavormap.properties file
> 
> Exception 
> /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/lib/flavormap.properties
> 

I looked into this a bit more.
As near as I can tell the code determining the location of the flavormap.properties file is in 
java.awt.datatransfer.SystemFlavorMap in the initSystemFlavorMap() method with…

                        String fileName =
                            System.getProperty("java.home") +
                            File.separator +
                            "lib" +
                            File.separator +
                            "flavormap.properties";

Another possibility for this would be something like…

public class FlavorFinder {

	public static void main(String[] args) {
		new FlavorFinder();
	}
	
	public FlavorFinder() {
		String rtpath = getClass().getClassLoader().getResource("java/lang/Object.class").getPath();
		String filePath = rtpath.substring(5,rtpath.indexOf("lib")+4) + "flavormap.properties";
		System.out.println(filePath);
	}
	
}

getting 
java FlavorFinder
/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/jre/lib/flavormap.properties
correct I believe for the jdk. 
Obviously a lot more inefficient than simply pasting together the string but my understanding of this class is that this is only done once so the performance hit wouldn't be a major concern. This hit would also probably not be at startup when performance might be more of a concern but later when clipboard access would be in use.

I may not be correct in my understanding here but I would think that any application run with the jdk would not correctly locate this file and then would not correctly handle cut and paste? I'd think jdk using applications like ide's might be impacted? 
My understanding might be wrong because my use is actually running from the jre with temporary OS X access to the jdk with…

	static {
		if (javaHome == null) {
			javaHome = rtexec(System.out,new String[] {"/usr/libexec/java_home","-v","1.7"}).trim();
			if (javaHome.equals("-")) javaHome = null;
			else {
				System.setProperty("java.home",javaHome);
			}
		}
	}

I could run the app jdk embedded to see if the problem is always there for the jdk runtime but have not.

I just wondered what problems there might be in determining the path based off of current runtime instead of trying to place it relative to java.home?

Michael Hall

trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz

HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe

AppConverter convert Apple jvm to openjdk apps http://www195.pair.com/mik3hall/index.html#appconverter



More information about the macosx-port-dev mailing list