Re: RFR (2nd): 8023524: Mechanism to dump generated lambda classes / log lambda code generation
On 9/24/2013 10:56 PM, Peter Levart wrote: Just a thought. How does URLClassLoader do the class name - path to resource translation? Perhaps there's already some code that does this correctly and in a platform-specific way (haven't looked)... sun.misc.ParseUtil.encodePath Mandy
Re: RFR (2nd): 8023524: Mechanism to dump generated lambda classes / log lambda code generation
On 09/25/2013 07:56 AM, Peter Levart wrote: Just a thought. How does URLClassLoader do the class name - path to resource translation? Perhaps there's already some code that does this correctly and in a platform-specific way (haven't looked)... Hi, sun.misc.ProxyGenerator has similar capability. It chooses to reject paths that are invalid for the underlying file system (using java.nio.file APIs)... Peter
Re: RFR (2nd): 8023524: Mechanism to dump generated lambda classes / log lambda code generation
On 09/24/2013 11:28 PM, Peter Levart wrote: On 09/25/2013 07:56 AM, Peter Levart wrote: Just a thought. How does URLClassLoader do the class name - path to resource translation? Perhaps there's already some code that does this correctly and in a platform-specific way (haven't looked)... Hi, sun.misc.ProxyGenerator has similar capability. It chooses to reject paths that are invalid for the underlying file system (using java.nio.file APIs)... Hi Peter, Thanks for the pointer, I asked similar question but didn't find this. It seems to me simply failed if classname contains invalid characters for the filesystem. I don't know enough to know whether that's appropriate at this moment. Our concern is that if it is possible to create file at bad places, and do our best to save the generated class file for captured lambda. With that, I guess current code is slightly better than previous one. Cheers, Henry
RFR (2nd): 8023524: Mechanism to dump generated lambda classes / log lambda code generation
Hi, Please review the new webrev at http://cr.openjdk.java.net/~henryjen/ccc/8023524/1/webrev/ The updated code will attempt to escape potentially bad characters(based on our best knowledge on Windows and common systems), it's not likely we can avoid problem for all file systems. Anyhow, we avoid characters that can be used to navigate (known) file system, and if there is any other invalid characters, that should cause an IOException failed to create file and just skip dumping of that class. Let me know if there are other concerns. Cheers, Henry On 09/19/2013 12:27 AM, Florian Weimer wrote: On 09/19/2013 01:00 AM, Henry Jen wrote: Class names can contain '\' and other characters which are problematic on Windows. Thanks for reviewing, I suspect you are pointing out a potential issue to look at, not that the problem exists in current implementation. According to JLS 3.8, the classname(an identifier) can only have letters, digits, plus '_' and '$'. You need to look at the JVM specification, there are only very few characters it excludes. The restrictions come from javac, not the JVM. For example, on Linux, java '\' will load a \.class file and run it (yes, I tried).
Re: RFR (2nd): 8023524: Mechanism to dump generated lambda classes / log lambda code generation
On 09/24/2013 11:59 PM, Henry Jen wrote: Hi, Please review the new webrev at http://cr.openjdk.java.net/~henryjen/ccc/8023524/1/webrev/ The updated code will attempt to escape potentially bad characters(based on our best knowledge on Windows and common systems), it's not likely we can avoid problem for all file systems. Anyhow, we avoid characters that can be used to navigate (known) file system, and if there is any other invalid characters, that should cause an IOException failed to create file and just skip dumping of that class. Let me know if there are other concerns. Hi Henry, Just a thought. How does URLClassLoader do the class name - path to resource translation? Perhaps there's already some code that does this correctly and in a platform-specific way (haven't looked)... Regards, Peter Cheers, Henry On 09/19/2013 12:27 AM, Florian Weimer wrote: On 09/19/2013 01:00 AM, Henry Jen wrote: Class names can contain '\' and other characters which are problematic on Windows. Thanks for reviewing, I suspect you are pointing out a potential issue to look at, not that the problem exists in current implementation. According to JLS 3.8, the classname(an identifier) can only have letters, digits, plus '_' and '$'. You need to look at the JVM specification, there are only very few characters it excludes. The restrictions come from javac, not the JVM. For example, on Linux, java '\' will load a \.class file and run it (yes, I tried).