We are having one functionality in our project in which we are having plugin in which custom ant tasks are implemented and those are consuming filesystem functionality (i.e EFS) from eclipse (i.e. org.eclipse.core.filesystem). These all was working fine when we were consuming the org.eclipse.core.filesystem_1.4.100.v20140514-1614.jar plugin.
Now, we started to upgrade the EFS filesystem dependency to org.eclipse.core.filesystem_1.7.700.v20200110-1734.jar plugin and it started to fail with below exception. This issue started to came after the fix of Bug 550548- Remove activator from org.eclipse.core.filesystem
Exception we are getting on execution of custom ant task which consuming EFS
C:\work\example\custom-ant-demo\build.xml:11: java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:148)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:137)
at org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.isLibraryPresent(UnixFileNatives.java:57)
at org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.(UnixFileNatives.java:47)
at org.eclipse.core.internal.filesystem.local.LocalFileNativesManager.(LocalFileNativesManager.java:42)
at org.eclipse.core.internal.filesystem.local.LocalFile.fetchInfo(LocalFile.java:162)
at org.eclipse.core.filesystem.provider.FileStore.fetchInfo(FileStore.java:260)
at com.custom.ant.example.GetFileAttributeTask.execute(GetFileAttributeTask.java:44)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.NullPointerException
at org.eclipse.core.internal.filesystem.FileSystemAccess.(FileSystemAccess.java:32)
... 23 more
Sample Project to reproduce the bug
We have created sample plugin (i.e. com.custom.ant.example) and uploaded with name com.custom.ant.example.zip. In this plugin, we have created GetFileAttributeTask.java custom task, In this task we are accepting the file with absolute path with the filePath attribute and by using that file path we are fetching the attributes of the file by using EFS. We have also attached the sample build.xml (i.e. build.zip) which is consuming this custom ant task (i.e. GetFileAttributeTask).
Please find below more details on how we are executing the ant task.
Command for custom ant execution
java -classpath <PATH_UPTO_ANT_LAUNCHER_JAR>\ant-launcher.jar org.apache.tools.ant.launch.Launcher -f <PATH_UPTO_BUILD_XML>\build.xml -lib <PATH_UPTO_PLUGIN_DEPENDENCY>
where
PATH_UPTO_ANT_LAUNCHER_JAR = directory upto the ant-launcher.jar.
PATH_UPTO_BUILD_XML = directory upto the build.xml. Here, build.xml is the file which is consuming the custom task created in our plugin
PATH_UPTO_PLUGIN_DEPENDENCY = this is the path upto the directory where all the dependent plugin present which are require to execute this custom ant task including the custom plugin. (i.e. com.custom.ant.example)
Below are the dependent plugin require to execute custom ant example
- com.custom.ant.example.jar
- org.eclipse.core.filesystem_1.7.700.v20200110-1734.jar
- org.eclipse.core.runtime_3.18.0.v20200506-2143.jar
- org.eclipse.equinox.common_3.12.0.v20200504-1602.jar
- org.eclipse.equinox.registry_3.8.800.v20200406-0956.jar
- org.eclipse.osgi_3.15.300.v20200520-1959.jar
Ouput of the above command if we use org.eclipse.core.filesystem_1.4.100.v20140514-1614.jar. Here everything works fine.
Buildfile: C:\work\example\custom-ant-demo\build.xml
all:
[customanttask] Hello, in the world of custom ant task!
[getfileattribute] filename : test.txt
[getfileattribute] Is Filename Executable : false
[getfileattribute] Is Filename Read Only : true
[getfileattribute] Is Filename Hidden : false
BUILD SUCCESSFUL
Total time: 0 seconds
Ouput of the above command if we use org.eclipse.core.filesystem_1.7.700.v20200110-1734.jar
Buildfile: C:\work\example\custom-ant-demo\build.xml
all:
[customanttask] Hello, in the world of custom ant task!
BUILD FAILED
C:\work\example\custom-ant-demo\build.xml:11: java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:148)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:137)
at org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.isLibraryPresent(UnixFileNatives.java:57)
at org.eclipse.core.internal.filesystem.local.unix.UnixFileNatives.(UnixFileNatives.java:47)
at org.eclipse.core.internal.filesystem.local.LocalFileNativesManager.(LocalFileNativesManager.java:42)
at org.eclipse.core.internal.filesystem.local.LocalFile.fetchInfo(LocalFile.java:162)
at org.eclipse.core.filesystem.provider.FileStore.fetchInfo(FileStore.java:260)
at com.custom.ant.example.GetFileAttributeTask.execute(GetFileAttributeTask.java:44)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.NullPointerException
at org.eclipse.core.internal.filesystem.FileSystemAccess.(FileSystemAccess.java:32)
... 23 more
Total time: 0 seconds