Working around native methods,

51 views
Skip to first unread message

Tiago Veloso

unread,
Apr 28, 2011, 9:41:29 AM4/28/11
to java-pa...@googlegroups.com, Tiago Veloso
So I have managed to solve that classpath problem (thanks Willem). Now I have another question.

I have ran JPF and got the following error:

com.puppycrawl.tools.checkstyle.api.CheckstyleException: unable to read sun_checks.xml - unable to read from stream
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:332)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:285)
at com.puppycrawl.tools.checkstyle.Main.loadConfig(Main.java:224)
at com.puppycrawl.tools.checkstyle.Main.main(Main.java:97)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: unable to read from stream
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:400)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:324)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:285)
at com.puppycrawl.tools.checkstyle.Main.loadConfig(Main.java:224)
at com.puppycrawl.tools.checkstyle.Main.main(Main.java:97)
Caused by: java.io.FileNotFoundException: /Users/fork/Documents/workspace/checkstyle-5.3/UTF-8
at java.io.FileInputStream.<init>(FileInputStream.java:36)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:653)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at com.puppycrawl.tools.checkstyle.api.AbstractLoader.parseInputSource(AbstractLoader.java:98)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.parseInputSource(ConfigurationLoader.java:272)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:383)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:324)
at com.puppycrawl.tools.checkstyle.ConfigurationLoader.loadConfiguration(ConfigurationLoader.java:285)
at com.puppycrawl.tools.checkstyle.Main.loadConfig(Main.java:224)
at com.puppycrawl.tools.checkstyle.Main.main(Main.java:97)

The error makes me believe that this is due to the use of Native methods that (as far as I know) JPF does not support. If this is the case how does one work around this limitation, if possible?

Tiago Veloso
ti.v...@gmail.com

Peter Mehlitz

unread,
Apr 28, 2011, 12:38:59 PM4/28/11
to java-pa...@googlegroups.com
that's not a missing native method, which should end in an UnsatisfiedLinkError. It doesn't find the file, and I don't see it in checkstyle, so I assume the filename construction fails somehow.

I've added a logger to our FileDescriptor native peer, activate it with "log.info=java.io.FileDescriptor"

-- Peter

Tiago Veloso

unread,
Apr 28, 2011, 1:52:43 PM4/28/11
to java-pa...@googlegroups.com, Tiago Veloso
Hi Peter,

Then I provably have something wrong with the properties file. However, this time I have copy pasted the target and target-args from the file to my console and I was able to run checkstyle without any issues using the following command:

java com.puppycrawl.tools.checkstyle.Main -c sun_checks.xml src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java

In the properties file it looks like:

target = com.puppycrawl.tools.checkstyle.Main

target_args = -c,sun_checks.xml,src/checkstyle/com/puppycrawl/tools/checkstyle/Checker.java

..... classpath and serach class ....

You are right, it is not finding a file, the file is UTF-8, which I also don't have, but that does not present a problem when running checkstyle with the regular VM.

Any idea what it might be?

Tiago Veloso
ti.v...@gmail.com

Peter C. Mehlitz

unread,
Apr 28, 2011, 3:01:02 PM4/28/11
to java-pa...@googlegroups.com
Hard to tell without the jdk6 and the checkstyle sources, but from
your stack trace I would assume that xerces (SAXParser impl) uses some
unset (system) properties during XML validation, which leads to a
incomplete/wrong pathname that causes the error

-- Peter

Tiago Veloso

unread,
Apr 28, 2011, 3:04:54 PM4/28/11
to java-pa...@googlegroups.com, Tiago Veloso
Do you know of a way to check the default java properties? The ones my OS sets by default? Perhaps I can set some of those variables in my JPF properties file.

Tiago Veloso
ti.v...@gmail.com

Peter C. Mehlitz

unread,
Apr 28, 2011, 3:19:04 PM4/28/11
to java-pa...@googlegroups.com
System.getProperties(), but that's too much. I assume something in
there points to your Java installation, which is then used to lookup a
property file.

Try to reproduce this with a simple example and I have a look

-- Peter

Tiago Veloso

unread,
Apr 28, 2011, 3:33:04 PM4/28/11
to java-pa...@googlegroups.com, Tiago Veloso
Yeah, I have remembered that method after I sent the email. Adding all those properties did not solve the problem, as you predicted. I am not familiar with Xerces to make a smaller example. I am trying to find where Xerces gets its properties so I can use them somehow.

I'll let you know my findings.

BTW, Checkstyle works on JDK 1.5, if you'd like to try it out.

Tiago Veloso
ti.v...@gmail.com

Reply all
Reply to author
Forward
0 new messages