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

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid unnecessary reflective probes on netty initialization (#14107) · netty/netty@db01c73

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • common/src/main/java/io/netty/util/internal
    • PlatformDependent0.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common/src/main/java/io/netty/util/internal/PlatformDependent0.java‎

Copy file name to clipboardExpand all lines: common/src/main/java/io/netty/util/internal/PlatformDependent0.java
+33-29Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,37 +153,41 @@ public Object run() {
153153
try {
154154
// Other methods like storeFence() and invokeCleaner() are tested for elsewhere.
155155
Class<? extends Unsafe> cls = finalUnsafe.getClass();
156-
cls.getDeclaredMethod("objectFieldOffset", Field.class);
157-
cls.getDeclaredMethod("staticFieldOffset", Field.class);
158-
cls.getDeclaredMethod("staticFieldBase", Field.class);
159-
cls.getDeclaredMethod("arrayBaseOffset", Class.class);
160-
cls.getDeclaredMethod("arrayIndexScale", Class.class);
161-
cls.getDeclaredMethod("allocateMemory", long.class);
162-
cls.getDeclaredMethod("reallocateMemory", long.class, long.class);
163-
cls.getDeclaredMethod("freeMemory", long.class);
164-
cls.getDeclaredMethod("setMemory", long.class, long.class, byte.class);
165-
cls.getDeclaredMethod("setMemory", Object.class, long.class, long.class, byte.class);
166156
cls.getDeclaredMethod(
167157
"copyMemory", Object.class, long.class, Object.class, long.class, long.class);
168-
cls.getDeclaredMethod("getBoolean", Object.class, long.class);
169-
cls.getDeclaredMethod("getByte", long.class);
170-
cls.getDeclaredMethod("getByte", Object.class, long.class);
171-
cls.getDeclaredMethod("getInt", long.class);
172-
cls.getDeclaredMethod("getInt", Object.class, long.class);
173-
cls.getDeclaredMethod("getLong", long.class);
174-
cls.getDeclaredMethod("getLong", Object.class, long.class);
175-
cls.getDeclaredMethod("putByte", long.class, byte.class);
176-
cls.getDeclaredMethod("putByte", Object.class, long.class, byte.class);
177-
cls.getDeclaredMethod("putInt", long.class, int.class);
178-
cls.getDeclaredMethod("putInt", Object.class, long.class, int.class);
179-
cls.getDeclaredMethod("putLong", long.class, long.class);
180-
cls.getDeclaredMethod("putLong", Object.class, long.class, long.class);
181-
cls.getDeclaredMethod("addressSize");
182-
// The following tests the methods are usable.
183-
// Will throw UnsupportedOperationException if unsafe memory access is denied:
184-
long address = finalUnsafe.allocateMemory(Long.BYTES);
185-
finalUnsafe.putLong(address, 42);
186-
finalUnsafe.freeMemory(address);
158+
if (javaVersion() > 23) {
159+
cls.getDeclaredMethod("objectFieldOffset", Field.class);
160+
cls.getDeclaredMethod("staticFieldOffset", Field.class);
161+
cls.getDeclaredMethod("staticFieldBase", Field.class);
162+
cls.getDeclaredMethod("arrayBaseOffset", Class.class);
163+
cls.getDeclaredMethod("arrayIndexScale", Class.class);
164+
cls.getDeclaredMethod("allocateMemory", long.class);
165+
cls.getDeclaredMethod("reallocateMemory", long.class, long.class);
166+
cls.getDeclaredMethod("freeMemory", long.class);
167+
cls.getDeclaredMethod("setMemory", long.class, long.class, byte.class);
168+
cls.getDeclaredMethod("setMemory", Object.class, long.class, long.class, byte.class);
169+
cls.getDeclaredMethod("getBoolean", Object.class, long.class);
170+
cls.getDeclaredMethod("getByte", long.class);
171+
cls.getDeclaredMethod("getByte", Object.class, long.class);
172+
cls.getDeclaredMethod("getInt", long.class);
173+
cls.getDeclaredMethod("getInt", Object.class, long.class);
174+
cls.getDeclaredMethod("getLong", long.class);
175+
cls.getDeclaredMethod("getLong", Object.class, long.class);
176+
cls.getDeclaredMethod("putByte", long.class, byte.class);
177+
cls.getDeclaredMethod("putByte", Object.class, long.class, byte.class);
178+
cls.getDeclaredMethod("putInt", long.class, int.class);
179+
cls.getDeclaredMethod("putInt", Object.class, long.class, int.class);
180+
cls.getDeclaredMethod("putLong", long.class, long.class);
181+
cls.getDeclaredMethod("putLong", Object.class, long.class, long.class);
182+
cls.getDeclaredMethod("addressSize");
183+
}
184+
if (javaVersion() >= 23) {
185+
// The following tests the methods are usable.
186+
// Will throw UnsupportedOperationException if unsafe memory access is denied:
187+
long address = finalUnsafe.allocateMemory(8);
188+
finalUnsafe.putLong(address, 42);
189+
finalUnsafe.freeMemory(address);
190+
}
187191
return null;
188192
} catch (UnsupportedOperationException e) {
189193
return e;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — 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.