GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • java.evolved

This view

  • Original page
  • New address

GeezerVison is showing javaevolved.dev — Migration — java.evolved

Home / Topics / Migration
🏷 Migration 5 patterns

Topic: Migration

All Java patterns related to Migration — java.evolved

I/O

Deprecated URL constructors to URI

Old URL endpoint = new URL("https://example.com/api?q=java");
Modern URI endpointUri = URI.create("https://example.com/api?q=java"); URL endpoint = endpointUri.toURL();
hover to see modern →
JDK 20+ learn more →
I/O

Finalizers to deterministic resource cleanup

Old @Override protected void finalize() throws Throwable { nativeHandle.release(); }
Modern final class NativeResource implements AutoCloseable { private static final Cleaner CLEANER = Cleaner.create(); private static final class State implements Runnable { private final long handle; State(long handle) { this.handle = handle; } @Override public void run() { release(handle); } } private final Cleaner.Cleanable cleanable; NativeResource(long handle) { cleanable = CLEANER.register(this, new State(handle)); } @Override public void close() { cleanable.clean(); } }
hover to see modern →
JDK 9+ learn more →
Security

SecurityManager checks to explicit authorization

Old SecurityManager manager = System.getSecurityManager(); if (manager != null) { manager.checkRead(path.toString()); } return Files.readString(path);
Modern // Untrusted users must not be able to modify this tree Path root = allowedRoot.toRealPath(); Path resolved = root.resolve(requested) .normalize() .toRealPath(); if (!resolved.startsWith(root)) { throw new SecurityException( "Path is outside the allowed root"); } return Files.readString(resolved);
hover to see modern →
JDK 24+ learn more →
Tooling

Class.newInstance() to constructor reflection

Old Plugin plugin = pluginClass.newInstance();
Modern Plugin plugin = pluginClass .getDeclaredConstructor() .newInstance();
hover to see modern →
JDK 9+ learn more →
Enterprise

Spring Boot MVC Configuration

Old @EnableWebMvc @Configuration public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addViewControllers( ViewControllerRegistry registry) { registry.addViewController("/").setViewName("home"); } }
Modern @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addViewControllers( ViewControllerRegistry registry) { registry.addViewController("/").setViewName("home"); } }
hover to see modern →
JDK 17+ learn more →
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.