Merge "Bug 582260 MAT 1.14.0 BouncyCastle CVE-2023-33201"
diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/views/NotesView.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/views/NotesView.java
index c8d580e..4b25462 100644
--- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/views/NotesView.java
+++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/internal/views/NotesView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2022 SAP AG and IBM Corporation.
+ * Copyright (c) 2008, 2023 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -593,14 +593,20 @@
// notes management
// //////////////////////////////////////////////////////////////
- private static String readNotes(File resourcePath)
+ /**
+ * Read the contents of the notes file, based on the
+ * snapshot resource.
+ * @param resourcePath The editor file (snapshot or index file).
+ * @return The contents of the notes file, lines separated by \n.
+ */
+ public static String readNotes(File resourcePath)
{
try
{
if (resourcePath != null)
{
File notesFile = getDefaultNotesFile(resourcePath);
- if (notesFile.exists())
+ if (notesFile.canRead())
{
FileInputStream fileInput = new FileInputStream(getDefaultNotesFile(resourcePath));
try
diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/Messages.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/Messages.java
index 8e7ed67..344aefe 100644
--- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/Messages.java
+++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2018 SAP AG and others.
+ * Copyright (c) 2008, 2023 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -49,6 +49,8 @@
public static String jvm_version;
+ public static String notes;
+
static
{
// initialize resource bundle
diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/SnapshotOutlinePage.java b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/SnapshotOutlinePage.java
index d8a5565..5c401e8 100644
--- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/SnapshotOutlinePage.java
+++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/SnapshotOutlinePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2021 SAP AG, IBM Corporation and others.
+ * Copyright (c) 2008, 2023 SAP AG, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
*
* Contributors:
* SAP AG - initial API and implementation
- * Andrew Johnson/IBM Corporation - com.ibm.icu fixes
+ * Andrew Johnson/IBM Corporation - com.ibm.icu fixes, notes
*******************************************************************************/
package org.eclipse.mat.ui.snapshot.views;
@@ -32,6 +32,7 @@
import org.eclipse.mat.snapshot.SnapshotInfo;
import org.eclipse.mat.snapshot.UnreachableObjectsHistogram;
import org.eclipse.mat.ui.accessibility.AccessibleCompositeAdapter;
+import org.eclipse.mat.ui.internal.views.NotesView;
import org.eclipse.mat.ui.snapshot.editor.ISnapshotEditorInput;
import org.eclipse.mat.ui.util.Copy;
import org.eclipse.mat.util.MessageUtil;
@@ -378,6 +379,10 @@
Serializable bDiscard_seed = bInfo.getProperty("discard_seed"); //$NON-NLS-1$
category.addChild(new Label(org.eclipse.mat.ui.Messages.UIPreferencePage_DiscardSeed, discard_seed, bDiscard_seed));
}
+ String note = getNotes(info);
+ String noteb = getNotes(bInfo);
+ if (note != null)
+ category.addChild(new Label(Messages.notes, note, noteb));
category = new Category(Messages.statistic_info);
elements.add(category);
@@ -421,7 +426,9 @@
final Double fileLength = Double.valueOf((double) osFile.length() / (1024 * 1024));
category.addChild(new Label(Messages.file_length, fileLength, null));
-
+ String note = getNotes(osFile);
+ if (note != null)
+ category.addChild(new Label(Messages.notes, note, null));
}
treeViewer.getTree().setRedraw(false);
@@ -430,6 +437,36 @@
treeViewer.getTree().setRedraw(true);
}
+ private String getNotes(SnapshotInfo info)
+ {
+ if (info != null)
+ {
+ String path = info.getPath();
+ String pfx = info.getPrefix();
+ if (path == null)
+ return null;
+ // See SnapshotHistoryFile#openFile
+ if (pfx != null && info.getProperty("$runtimeId") != null) //$NON-NLS-1$
+ {
+ return getNotes(new File(pfx + "index")); //$NON-NLS-1$
+ }
+ else
+ {
+ return getNotes(new File(path));
+ }
+ }
+ return null;
+ }
+
+ private String getNotes(File snapshotFile)
+ {
+ String notes = NotesView.readNotes(snapshotFile);
+ // Just use the first line
+ if (notes != null)
+ return notes.split("\n", 2)[0]; //$NON-NLS-1$
+ return null;
+ }
+
private long[] unreachableObjects(SnapshotInfo info)
{
long discardedObjects = 0;
diff --git a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/messages.properties b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/messages.properties
index 0f744f4..ecf2822 100644
--- a/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/messages.properties
+++ b/plugins/org.eclipse.mat.ui/src/org/eclipse/mat/ui/snapshot/views/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2013, 2018 SAP AG and others.
+# Copyright (c) 2013, 2023 SAP AG and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
@@ -39,4 +39,4 @@
baseline=Baseline
jvm_version=JVM version
-
+notes=Notes