Skip to content

Commit

Permalink
8345049: Remove the jmx.tabular.data.hash.map compatibility property
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjwalls committed Jan 16, 2025
1 parent d23ad01 commit 70313d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -143,16 +143,9 @@ public TabularDataSupport(TabularType tabularType, int initialCapacity, float lo
List<String> tmpNames = tabularType.getIndexNames();
this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]);

// Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
// if very unlikely that we might be the server of a 1.3 client. In
// that case you'll need to set this property. See CR 6334663.
boolean useHashMap = Boolean.getBoolean("jmx.tabular.data.hash.map");

// Construct the empty contents HashMap
//
this.dataMap = useHashMap ?
new HashMap<>(initialCapacity, loadFactor) :
new LinkedHashMap<>(initialCapacity, loadFactor);
this.dataMap = new LinkedHashMap<>(initialCapacity, loadFactor);
}


Expand Down
42 changes: 1 addition & 41 deletions test/jdk/javax/management/openmbean/TabularDataOrderTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -57,8 +57,6 @@
public class TabularDataOrderTest {
private static String failure;

private static final String COMPAT_PROP_NAME = "jmx.tabular.data.hash.map";

private static final String[] intNames = {
"unus", "duo", "tres", "quatuor", "quinque", "sex", "septem",
"octo", "novem", "decim",
Expand Down Expand Up @@ -129,44 +127,6 @@ public static void main(String[] args) throws Exception {
if (!ordered)
fail("Order not preserved");

// Now test the undocumented property that causes HashMap to be used
// instead of LinkedHashMap, in case serializing to a 1.3 client.
// We serialize and deserialize in case the implementation handles
// this at serialization time. Then we look at object fields; that's
// not guaranteed to work but at worst it will fail spuriously and
// we'll have to update the test.
System.out.println("Testing compatible behaviour");
System.setProperty(COMPAT_PROP_NAME, "true");
td = makeTable();
System.out.println(td);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(td);
oout.close();
byte[] bytes = bout.toByteArray();
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
ObjectInputStream oin = new ObjectInputStream(bin);
td = (TabularData) oin.readObject();
boolean found = false;
for (Field f : td.getClass().getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers()))
continue;
f.setAccessible(true);
Object x = f.get(td);
if (x != null && x.getClass() == HashMap.class) {
found = true;
System.out.println(
x.getClass().getName() + " TabularDataSupport." +
f.getName() + " = " + x);
break;
}
}
if (!found) {
fail("TabularDataSupport does not contain HashMap though " +
COMPAT_PROP_NAME + "=true");
}
System.clearProperty(COMPAT_PROP_NAME);

System.out.println("Testing MXBean behaviour");
MBeanServer mbs = MBeanServerFactory.newMBeanServer();
ObjectName name = new ObjectName("a:b=c");
Expand Down

0 comments on commit 70313d0

Please sign in to comment.