Skip to content

Commit 3f946fd

Browse files
committed
Fix netCDF-C loading in RuntimeConfigParser
Use the correct method name when loading the library by name and path. Fixes #1473
1 parent 00fdf39 commit 3f946fd

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

cdm/core/src/main/java/ucar/nc2/NetcdfFileWriter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ protected NetcdfFileWriter(Version version, String location, boolean isExisting,
194194
if (version.useJniIosp()) {
195195
IOServiceProviderWriter spi;
196196
try {
197-
// Nc4Iosp.setLibraryAndPath(path, name);
198197
Class iospClass = this.getClass().getClassLoader().loadClass("ucar.nc2.jni.netcdf.Nc4Iosp");
199198
Constructor<IOServiceProviderWriter> ctor = iospClass.getConstructor(Version.class);
200199
spi = ctor.newInstance(version);

cdm/core/src/main/java/ucar/nc2/util/xml/RuntimeConfigParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public static void read(org.jdom2.Element root, StringBuilder errlog) {
269269
// so we cannot refer to the Nc4Iosp.class and NetcdfClibrary.class object.
270270
String nc4IospClassName = "ucar.nc2.jni.netcdf.Nc4Iosp";
271271
// The setLibraryAndPath method from Nc4Iosp has been deprecated
272-
// and splited into separated class: NetcdfClibrary
272+
// and split into separated class: NetcdfClibrary
273273
String netcdfClibraryClassName = "ucar.nc2.ffi.netcdf.NetcdfClibrary";
274274
/*
275275
* <Netcdf4Clibrary>
@@ -285,8 +285,8 @@ public static void read(org.jdom2.Element root, StringBuilder errlog) {
285285
if (path != null && name != null) {
286286
// reflection is used to decouple optional jars
287287
try {
288-
Class netcdfClibraryClass = RuntimeConfigParser.class.getClassLoader().loadClass(netcdfClibraryClassName);
289-
Method method = netcdfClibraryClass.getMethod("setLibraryAndPath", String.class, String.class);
288+
Class<?> netcdfClibraryClass = RuntimeConfigParser.class.getClassLoader().loadClass(netcdfClibraryClassName);
289+
Method method = netcdfClibraryClass.getMethod("setLibraryNameAndPath", String.class, String.class);
290290
method.invoke(null, path, name); // static method has null for object
291291
} catch (Throwable e) {
292292
errlog.append(netcdfClibraryClassName + " is not on classpath\n");

0 commit comments

Comments
 (0)