☕ Java 26 — JEP 500: Prepare to make final mean final class C { final int x; C() {x = 100;} } static void main() throws NoSuchFieldException, IllegalAccessException { var f = C.class.getDeclaredField( "x" ); f.setAccessible( true ); var obj = new JEP500().new C(); IO.println( obj.x ); f.set( obj, 200 ); IO.println( obj.x ); /*output: 100 200 WARNING: Final field x in class com.vv.JEP500$C has been mutated ... WARNING: Use --enable-final-field-mutation=ALL-UNNAMED ... WARNING: Mutating final fields will be blocked in a future release .... */ } • JDK 26 starts warning about deep reflection that mutates final fields. • This prepares the ecosystem for a future release where such mutation is denied by default. • For developers, the action item is simple: run tests, find reflection-heavy libraries, and see who still breaks final. #java #java26 #final Go further with Java certification: Java👇 https://bit.ly/javaOCP Spring👇 https://bit.ly/2v7222 SpringBook👇 https://bit.ly/springtify JavaBook👇 https://bit.ly/jroadmap
More Relevant Posts
-
Java is quietly becoming more expressive This is not the Java you learned 5 years ago. Modern Java (21 → 25) is becoming much more concise and safer. 🧠 Old Java if (obj instanceof User) { User user = (User) obj; return user.getName(); } else if (obj instanceof Admin) { Admin admin = (Admin) obj; return admin.getRole(); } 👉 verbose 👉 error-prone 👉 easy to forget cases 🚀 Modern Java return switch (obj) { case User user -> user.getName(); case Admin admin -> admin.getRole(); default -> throw new IllegalStateException(); }; ⚡ Even better with sealed classes Java sealed interface Account permits User, Admin {} 👉 Now the compiler knows all possible types 👉 and forces you to handle them 💥 Why this matters less boilerplate safer code (exhaustive checks) fewer runtime bugs 👉 the compiler does more work for you ⚠️ What I still see in real projects old instanceof patterns manual casting everywhere missing edge cases 🧠 Takeaway Modern Java is not just about performance. It’s about writing safer and cleaner code. 🔍 Bonus Once your code is clean, the next challenge is making it efficient. That’s what I focus on with: 👉 https://joptimize.io Are you still writing Java 8-style code in 2025? #JavaDev #Java25 #Java21 #CleanCode #Backend #SoftwareEngineering
To view or add a comment, sign in
-
Java 26 is here, and it's one of the most practical releases in years. !!! Released on March 17, 2026, Java 26 may not have flashy headline features, but it introduces 10 solid JEPs that enhance the platform's performance, safety, and intelligence. Key updates for enterprise Java developers include: ⚡ G1 GC throughput boost (JEP 522): Reduced synchronization between application threads and GC threads leads to more work done per second, with no code changes needed—your application simply gets faster. 🚀 AOT Caching now works with ZGC (JEP 516): Project Leyden enables AOT object caching for all garbage collectors, including ZGC, resulting in faster startup and low-latency GC in production. Lambda and containerized Java have reached a new level. 🌐 HTTP/3 in the standard HTTP Client (JEP 517): Java's built-in client now supports HTTP/3, offering lower latency, no head-of-line blocking, and improved mobile performance, all with minimal code changes. 🔐 Final means Final again (JEP 500): Java is addressing a 30-year loophole—reflective mutation of final fields will now trigger warnings and be blocked in a future release, promoting "integrity by default." 🪦 Goodbye, Applets (JEP 504): After being deprecated in Java 9 and marked for removal in Java 17, Applets are finally gone in Java 26. The bigger picture? This marks the 17th consecutive on-time release under the 6-month cadence. Java is not just alive; it's functioning like a well-run product team. #Java #Java26 #JVM #SpringBoot #BackendEngineering #Microservices #SoftwareEngineering #systemdesign #distributedsystems
To view or add a comment, sign in
-
Why Java uses references instead of direct object access ? In Java, you never actually deal with objects directly. You deal with references to objects. That might sound small - but it changes everything. When you create an object: You’re not storing the object itself. You’re storing a reference (address) to where that object lives in memory. Why does Java do this? 1️⃣ Memory efficiency Passing references is cheaper than copying entire objects. 2️⃣ Flexibility Multiple references can point to the same object. That’s how shared data and real-world systems work. 3️⃣ Garbage Collection Java tracks references - not raw memory. When no references point to an object, it becomes eligible for cleanup. 4️⃣ Abstraction & Safety Unlike languages with pointers, Java hides direct memory access. This prevents accidental memory corruption. When you pass an object to a method, you’re passing the reference by value - not the object itself. That’s why changes inside methods can affect the original object. The key idea: Java doesn’t give you objects. It gives you controlled access to objects through references. #Java #JavaProgramming #CSFundamentals #BackendDevelopment #OOP
To view or add a comment, sign in
-
-
🔹 Java 8 (Released 2014) – Foundation Release This is still widely used in many projects. Key Features: Lambda Expressions Functional Interfaces Streams API Method References Optional Class Default & Static methods in interfaces Date & Time API (java.time) Nashorn JavaScript Engine 👉 Example: Java list.stream().filter(x -> x > 10).forEach(System.out::println); 🔹 Java 17 (LTS – 2021) – Modern Java Standard Most companies are moving to this LTS version. Key Features: Sealed Classes Pattern Matching (instanceof) Records (finalized) Text Blocks (multi-line strings) New macOS rendering pipeline Strong encapsulation of JDK internals Removed deprecated APIs (like Nashorn) 👉 Example: Java record Employee(String name, int salary) {} 🔹 Java 21 (LTS – 2023) – Latest Stable LTS 🚀 Highly recommended for new projects. Key Features: Virtual Threads (Project Loom) ⭐ (BIGGEST CHANGE) Structured Concurrency (preview) Scoped Values (preview) Pattern Matching for switch (final) Record Patterns Sequenced Collections String Templates (preview) 👉 Example (Virtual Thread): Java Thread.startVirtualThread(() -> { System.out.println("Lightweight thread"); }); 🔹 Java 26 (Future / Latest Enhancements – Expected 2026) ⚡ (Not all finalized yet, but based on current roadmap & previews) Expected / Emerging Features: Enhanced Pattern Matching Primitive Types in Generics (Project Valhalla) ⭐ Value Objects (no identity objects) Improved JVM performance & GC Better Foreign Function & Memory API More concurrency improvements Scoped/Structured concurrency finalized 👉 Example (Concept): Java List<int> numbers; // possible future feature
To view or add a comment, sign in
-
🚨 Java 26 is out. And most people are asking the wrong question. "Why so fast?" isn't the right concern. The right one is: are you actually using what Java already gave you? Java moved to a 6-month release cadence in 2018. That's not speed for the sake of speed — it's incremental pressure on the runtime, informed by real production feedback. And Java 26 continues exactly that. Here's what actually matters in this release — and why it's more subtle than it looks: Virtual Threads are maturing. Not new. But the edge cases that broke thread-local assumptions in frameworks like Hibernate and Spring are being addressed. If your team avoided Project Loom because of compatibility concerns — that wall is getting shorter. ZGC sub-millisecond pauses are now the expectation, not the exception. If your application still shows GC pauses above 5ms under load, that's not a Java problem anymore. That's a tuning problem. The JVM held up its end of the deal. The JIT keeps getting smarter about escape analysis. Short-lived objects that never leave a method scope increasingly never hit the heap at all. Stack allocation, no GC pressure. If you're still pre-allocating object pools "for performance" without profiling first — you might be solving a problem the JVM already solved. The pattern across all of this? The JVM is absorbing complexity so your architecture doesn't have to. The question was never "why Java 26 so soon." It's: are you writing code that takes advantage of a runtime this good? 💬 What's the one JVM behavior you've had to work around that you suspect modern Java already handles? #Java #JVM #Backend #SoftwareEngineering #Performance #VirtualThreads
To view or add a comment, sign in
-
-
Hello Connections, Post 19— Java Fundamentals A-Z This looks safe… but can crash your app instantly 💀 Can you spot the bug? 👇 Map<String, String> map = new HashMap<>(); map.put("key", null); if (map.get("key").equals("value")) { System.out.println("Matched"); // 💀 Boom! } Looks normal right? 😬 But this throws: 👉 NullPointerException What went wrong? 👇 * map.get("key") returns null * Calling .equals() on null → 💥 crash ⚠️ Result: * Runtime failure * Hard-to-debug issue Here’s the fix 👇 if ("value".equals(map.get("key"))) { System.out.println("Matched"); // ✅ Safe } 👉 Constant comes first → avoids NPE Alternative 👇 if (Objects.equals(map.get("key"), "value")) { System.out.println("Matched"); // ✅ Null-safe } Post 19 Summary: 🔴 Unlearned → Calling methods on possibly null values 🟢 Relearned → Use constant-first .equals() or Objects.equals() ⸻ Have you ever faced this crash? Drop a 💥 below! Follow along for more Java & backend concepts 👇 #Java #JavaFundamentals #BackendDevelopment #LearningInPublic #SDE2
To view or add a comment, sign in
-
-
Since Java 10, Java introduced a handy feature called var that allows the compiler to infer the type of local variables from their initializer, making code easier to read. // Without var String name = "Java"; URL url = new URL("http://google.com"); // With var var name = "Java"; var url = new URL("http://google.com"); Here are the best way to use it: Use var when: • The type is obvious from the constructor: var list = new ArrayList<String>(); (No need to write ArrayList<String>() twice) • Handling complex generics: Prefer: var map = new HashMap<String, List<Order>>(); than: Map<String, List<Order>> map = new HashMap<String, List<Order>>(); • The variable name provides enough context: var customer = service.findCustomerById(id); (The name customer tells what it is) Avoid var when: • The initializer is not obvious: var result = o.calculate(); (Hard to tell if result is an int, a double or a Result object...) • The variable has a long scope: if a method is 50 lines long, using var at the top makes it harder to remember the type when reaching the bottom. • Using var in method signatures (not allowed anyway): Java only allows var for local variables, not fields, parameters, or return types.
To view or add a comment, sign in
-
You have written thousands of Java objects. You have never actually seen one. Not the real thing — the bytes sitting on the heap, the hidden 12-byte header every object carries before a single field is stored, the padding the JVM adds without asking. Java 25 just made that header smaller for the first time in 13 years. I ran JOL (Java Object Layout) on the same Point(int x, int y) record on Java 21 and Java 25. Here is what came back: Java 21 → 24 bytes Java 25 → 16 bytes At 1 million objects that is 8 MB freed. At the allocation rates of a typical Spring Boot service, that is measurable GC pressure gone. The article walks through the actual JOL output byte by byte — the header tax, how it works, why it took 13 years to fix, and what it means if you are running services on AWS or Kubernetes. #Java #Java25 #JVM #SpringBoot #BackendDevelopment #SoftwareEngineering #Performance
To view or add a comment, sign in
-
⚠️ Why Java Killed PermGen (And What Replaced It) Before Java 8, JVM had PermGen (Permanent Generation) A special memory region inside the heap used for: Class metadata Method metadata String intern pool (pre-Java 7) Static variables The Problem was with PermGen as it had a fixed size: -XX:MaxPermSize=256m Sounds fine until: Applications dynamically load classes Frameworks create proxies (Spring, Hibernate) ClassLoaders don’t get garbage collected 👉 Boom: OutOfMemoryError: PermGen space Very common in: App servers Long-running systems Hot-deploy environments 🧠 Enter Metaspace (Java 8+) PermGen was removed and replaced with Metaspace Key change: Moved class metadata OUT of heap → into native memory ⚡ What Changed? Memory Location Native memory Size Dynamic (auto grows) Tuning Minimal OOM Errors Frequent Much rarer 🧠 Why This Was a Big Deal Metaspace: Grows dynamically (no fixed ceiling by default) Reduces OOM crashes Simplifies JVM tuning Handles dynamic class loading better But It’s Not “Unlimited" If not controlled It can still cause: OutOfMemoryError: Metaspace So you can still set limits: -XX:MaxMetaspaceSize=512m 🧠 What Actually Lives in Metaspace? Class metadata Method metadata Runtime constant pool NOT: Objects (Heap) Stack frames (Stack) PermGen failed because it was fixed. Metaspace works because it adapts. #Java #JVM #MemoryManagement #Metaspace #PerformanceEngineering #BackendDevelopment #JavaInternals #LearnInPublic
To view or add a comment, sign in
-
Most Java developers write this code every day. And don't realize it's making 50 database calls instead of 1. 🧵 It looks completely fine: List<Orders> orders = orderRepository.findAll(); for (Order order : orders) { System.out.println(order.getUser().getName()); } Clean. Readable. Innocent. But here's what's actually happening behind the scenes: 👉 1 query to fetch all orders 👉 1 query PER order to fetch the user 50 orders = 51 queries. 500 orders = 501 queries. This is the N+1 problem. And it silently kills performance. I hit this exact issue in my project. API response was creeping from 300ms to 2+ seconds. No errors. Nothing in logs. Just slow. Profiled it. Found 51 database calls for a simple list fetch. The fix was 1 line: @Query("SELECT o FROM Order o JOIN FETCH o.user") List<Order> findAllWithUser(); Result: 2100ms → 290ms ⚡ Why does this happen? JPA's default fetch type is LAZY — it waits until you access the relationship to query it. Inside a loop, that means one query per iteration. JOIN FETCH tells Hibernate — get everything in one query. The rule I follow now: If you're looping through entities and accessing relationships — always check your query count first. One annotation. Massive difference. Have you run into N+1 in your project? 👇 #Java #SpringBoot #Hibernate #JPA #BackendDevelopment #JavaDeveloper #SoftwareEngineering
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development