Skip to content

Commit

Permalink
Ensuring JDK 1.8 - JDK 21 support. Class fileformat 52.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Nov 1, 2023
1 parent 78ff1de commit 36b56c0
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 115 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,25 @@ java-util


Rare, hard-to-write utilities that are thoroughly tested (> 98% code coverage via JUnit tests). This library has <b>no
dependencies</b> on other libraries for runtime. Built purely on JDK.
dependencies</b> on other libraries for runtime. Built purely on JDK. Works with JDK 1.8 through JDK 21.

To include in your project:
##### Gradle
```
implementation 'com.cedarsoftware:java-util:2.1.1'
implementation 'com.cedarsoftware:java-util:2.2.0'
```

##### Maven
```
<dependency>
<groupId>com.cedarsoftware</groupId>
<artifactId>java-util</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
</dependency>
```

The java-util jar is about 150K in size.
The java-util jar is about **150K** in size.

### Sponsors
[![Alt text](https://www.yourkit.com/images/yklogo.png "YourKit")](https://www.yourkit.com/.net/profiler/index.jsp)

YourKit supports open source projects with its full-featured Java Profiler.
YourKit, LLC is the creator of <a href="https://www.yourkit.com/java/profiler/index.jsp">YourKit Java Profiler</a>
and <a href="https://www.yourkit.com/.net/profiler/index.jsp">YourKit .NET Profiler</a>,
innovative and intelligent tools for profiling Java and .NET applications.

<a href="https://www.jetbrains.com/idea/"><img alt="Intellij IDEA from JetBrains" src="https://s-media-cache-ak0.pinimg.com/236x/bd/f4/90/bdf49052dd79aa1e1fc2270a02ba783c.jpg" data-canonical-src="https://s-media-cache-ak0.pinimg.com/236x/bd/f4/90/bdf49052dd79aa1e1fc2270a02ba783c.jpg" width="100" height="100" /></a>
**Intellij IDEA**<hr>

Since Java 1.5, you can statically import classes. Using this technique with many of the classes below, it makes their methods directly accessible in your source code, keeping your source code smaller and easier to read. For example:

Expand Down Expand Up @@ -85,4 +75,16 @@ Included in java-util:

See [changelog.md](/changelog.md) for revision history.

### Sponsors
[![Alt text](https://www.yourkit.com/images/yklogo.png "YourKit")](https://www.yourkit.com/.net/profiler/index.jsp)

YourKit supports open source projects with its full-featured Java Profiler.
YourKit, LLC is the creator of <a href="https://www.yourkit.com/java/profiler/index.jsp">YourKit Java Profiler</a>
and <a href="https://www.yourkit.com/.net/profiler/index.jsp">YourKit .NET Profiler</a>,
innovative and intelligent tools for profiling Java and .NET applications.

<a href="https://www.jetbrains.com/idea/"><img alt="Intellij IDEA from JetBrains" src="https://s-media-cache-ak0.pinimg.com/236x/bd/f4/90/bdf49052dd79aa1e1fc2270a02ba783c.jpg" data-canonical-src="https://s-media-cache-ak0.pinimg.com/236x/bd/f4/90/bdf49052dd79aa1e1fc2270a02ba783c.jpg" width="100" height="100" /></a>
**Intellij IDEA**<hr>


By: John DeRegnaucourt and Ken Partlow
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### Revision History
* 2.2.0
* Built with JDK 1.8 and runs with JDK 1.8 through JDK 21.
* The 2.2.x will continue to maintain JDK 1.8. The 3.0 branch [not yet created] will be JDK11+
* Added tests to verify that `GraphComparator` and `DeepEquals` do not count sorted order of Sets for equivalency. It does however, require `Collections` that are not `Sets` to be in order.
* 2.1.1
* ReflectionUtils skips static fields, speeding it up and remove runtime warning (field SerialVersionUID). Supports JDK's up through 21.
* 2.1.0
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.cedarsoftware</groupId>
<artifactId>java-util</artifactId>
<packaging>jar</packaging>
<version>2.1.2-SNAPSHOT</version>
<version>2.2.0</version>
<description>Java Utilities</description>
<url>https://github.com/jdereg/java-util</url>

Expand All @@ -19,15 +19,15 @@

<properties>
<!-- Java source, target, and release version -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- <maven.compiler.release>11</maven.compiler.release>-->

<!-- testing only -->
<version.junit>5.10.0</version.junit>
<version.assertj>3.24.2</version.assertj>
<version.json.io>4.14.1</version.json.io>
<version.mockito.inline>5.2.0</version.mockito.inline>
<version.mockito.inline>4.11.0</version.mockito.inline>
<version.agrona>1.19.2</version.agrona>

<!-- release plugin -->
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cedarsoftware/util/CompactMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public Iterator<V> iterator()

public Set<Entry<K, V>> entrySet()
{
return new AbstractSet<>()
return new AbstractSet()
{
public Iterator<Entry<K, V>> iterator()
{
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/cedarsoftware/util/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ public static void getDeclaredFields(Class<?> c, Collection<Field> fields) {
}
else
{
field.trySetAccessible();
// JDK11+ field.trySetAccessible();
try
{
field.setAccessible(true);
}
catch(Exception e) { }
// JDK11+
fields.add(field);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/cedarsoftware/util/UniqueIdGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ private UniqueIdGenerator()
private static long previousTimeMilliseconds = 0;
private static long previousTimeMilliseconds2 = 0;
private static final int serverId;
private static final Map<Long, Long> lastIds = new LinkedHashMap<>()
private static final Map<Long, Long> lastIds = new LinkedHashMap()
{
protected boolean removeEldestEntry(Map.Entry<Long, Long> eldest)
protected boolean removeEldestEntry(Map.Entry eldest)
{
return size() > 1000;
}
};
private static final Map<Long, Long> lastIdsFull = new LinkedHashMap<>()
private static final Map<Long, Long> lastIdsFull = new LinkedHashMap()
{
protected boolean removeEldestEntry(Map.Entry<Long, Long> eldest)
protected boolean removeEldestEntry(Map.Entry eldest)
{
return size() > 10000;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ private CaseInsensitiveMap<String, Object> createSimpleMap()

private Map.Entry<String, Object> getEntry(final String key, final Object value)
{
return new Map.Entry<>()
return new Map.Entry()
{
Object myValue = value;

Expand Down
Loading

0 comments on commit 36b56c0

Please sign in to comment.