diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java index 4ec3a24ea9a..bb3514be1d0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java @@ -26,8 +26,9 @@ public class ElfBinaryArchive extends PlatformObject implements IBinaryArchive { ArrayList children; long timestamp; - public ElfBinaryArchive(IPath p) { + public ElfBinaryArchive(IPath p) throws IOException { path = p; + new AR(path.toOSString()).dispose(); // check file type children = new ArrayList(5); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java index 61f2509cf96..7a8480d4320 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java @@ -274,9 +274,15 @@ public class ElfBinaryFile extends PlatformObject implements IBinaryFile, IBinar } protected void loadInformation() throws IOException { - ElfHelper helper = getElfHelper(); - loadInformation(helper); - helper.dispose(); + ElfHelper helper = null; + try { + helper = getElfHelper(); + loadInformation(helper); + } finally { + if (helper != null) { + helper.dispose(); + } + } } private void loadInformation(ElfHelper helper) throws IOException { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java index 8defeef32c0..ffad041aaff 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java @@ -9,8 +9,6 @@ import java.io.IOException; import org.eclipse.cdt.core.AbstractCExtension; import org.eclipse.cdt.core.IBinaryParser; -import org.eclipse.cdt.utils.elf.AR; -import org.eclipse.cdt.utils.elf.Elf; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -25,16 +23,13 @@ public class ElfParser extends AbstractCExtension implements IBinaryParser { if (path == null ) { path = new Path(""); } + IBinaryFile bFile; try { - Elf e = new Elf(path.toOSString()); - e.dispose(); - return new ElfBinaryFile(path); + bFile = new ElfBinaryFile(path); } catch (IOException e) { + bFile = new ElfBinaryArchive(path); } - // Is it an Archive. - AR ar = new AR(path.toOSString()); - ar.dispose(); - return new ElfBinaryArchive(path); + return bFile; } /**