Skip to content

Commit 444f5fc

Browse files
committed
Bug 37836205 - [37834715->25.03.1] Update PortableTypeGenerator to use ClassReaderInternal instead of ClassReader (merge ce/main -> ce/25.03 @ 115630)
[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v25.03/": change = 115631]
1 parent 29c7dad commit 444f5fc

File tree

5 files changed

+98
-15
lines changed

5 files changed

+98
-15
lines changed

prj/coherence-core/src/main/java/com/tangosol/internal/asm/ClassReaderInternal.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -48,12 +48,20 @@ public ClassReaderInternal(byte[] abBytes)
4848
super(abBytes);
4949
}
5050

51+
/**
52+
* @see BaseClassReaderInternal#BaseClassReaderInternal(byte[], int, int)
53+
*/
54+
public ClassReaderInternal(byte[] abBytes, int cOffset, int cLength)
55+
{
56+
super(abBytes, cOffset, cLength);
57+
}
58+
5159
// ----- BaseClassReaderInternal methods --------------------------------
5260

5361
@Override
54-
protected ClassReader createReader(byte[] abBytes)
62+
protected ClassReader createReader(byte[] abBytes, int cOffset, int cLength)
5563
{
56-
return new ClassReader(abBytes);
64+
return new ClassReader(abBytes, cOffset, cLength);
5765
}
5866

5967
@Override

prj/coherence-core/src/main/java/com/tangosol/io/pof/generator/PortableTypeGenerator.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
2-
* Copyright (c) 2013, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.io.pof.generator;
88

9+
import com.tangosol.internal.asm.ClassReaderInternal;
10+
911
import com.tangosol.io.pof.RawDate;
1012
import com.tangosol.io.pof.RawDateTime;
1113
import com.tangosol.io.pof.RawDayTimeInterval;
@@ -170,7 +172,7 @@ public PortableTypeGenerator(Schema schema, InputStream in, boolean fDebug)
170172
public PortableTypeGenerator(Schema schema, InputStream in, boolean fDebug, Logger logger)
171173
throws IOException
172174
{
173-
this(schema, new ClassReader(in), fDebug, logger);
175+
this(schema, new ClassReaderInternal(in), fDebug, logger);
174176
}
175177

176178
/**
@@ -185,7 +187,7 @@ public PortableTypeGenerator(Schema schema, InputStream in, boolean fDebug, Logg
185187
*/
186188
public PortableTypeGenerator(Schema schema, byte[] bytes, int nOffset, int nLen, boolean fDebug, Logger logger)
187189
{
188-
this(schema, new ClassReader(bytes, nOffset, nLen), fDebug, logger);
190+
this(schema, new ClassReaderInternal(bytes, nOffset, nLen), fDebug, logger);
189191
}
190192

191193
/**
@@ -215,6 +217,35 @@ public PortableTypeGenerator(Schema schema, ClassReader reader, boolean fDebug,
215217
}
216218
}
217219

220+
/**
221+
* Create a {@link PortableTypeGenerator}.
222+
*
223+
* @param schema the {@link Schema} instance to use
224+
* @param reader the {@link ClassReaderInternal} containing the class to instrument
225+
* @param fDebug flag indicating whether to generate debug code
226+
* @param logger the {@link Logger} to use
227+
*
228+
* @since 25.03.1
229+
*/
230+
protected PortableTypeGenerator(Schema schema, ClassReaderInternal reader, boolean fDebug, Logger logger)
231+
{
232+
m_schema = schema;
233+
m_fDebug = fDebug;
234+
m_log = logger;
235+
236+
ClassNode cn = new ClassNode();
237+
238+
reader.accept(cn, 0);
239+
240+
m_classNode = cn;
241+
242+
com.oracle.coherence.common.schema.Type<?, ?> type = m_schema.findTypeByJavaName(javaName(cn.name));
243+
if (type != null)
244+
{
245+
m_type = (PofType) type.getExtension(PofType.class);
246+
}
247+
}
248+
218249
// ----- PortableTypeGenerator methods ----------------------------------
219250

220251
/**

prj/coherence-core/src/main/java/com/tangosol/util/asm/BaseClassReaderInternal.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,20 @@ public BaseClassReaderInternal(InputStream streamIn)
3636
* @see org.objectweb.asm.ClassReader#ClassReader(byte[])
3737
*/
3838
public BaseClassReaderInternal(byte[] abBytes)
39+
{
40+
this(abBytes, 0, abBytes.length);
41+
}
42+
43+
/**
44+
* @see org.objectweb.asm.ClassReader#ClassReader(byte[], int, int)
45+
*
46+
* @since 25.03.1
47+
*/
48+
public BaseClassReaderInternal(byte[] abBytes, int cOffset, int cLength)
3949
{
4050
m_abBytes = abBytes;
51+
m_cOffset = cOffset;
52+
m_cLength = cLength;
4153
}
4254

4355
// ----- abstract methods -----------------------------------------------
@@ -46,10 +58,12 @@ public BaseClassReaderInternal(byte[] abBytes)
4658
* Create the module-specific ClassReader.
4759
*
4860
* @param abBytes the class bytes
61+
* @param cOffset the starting offset
62+
* @param cLength the class length
4963
*
5064
* @return the module-specific ClassReader
5165
*/
52-
protected abstract RT createReader(byte[] abBytes);
66+
protected abstract RT createReader(byte[] abBytes, int cOffset, int cLength);
5367

5468
/**
5569
* Perform the accept operation on the module-specific ClassReader
@@ -88,7 +102,7 @@ public void accept(CVT classVisitor, int nParsingOptions)
88102
Logger.warn(() -> String.format("Unsupported class file major version " + nOriginalVersion));
89103
}
90104

91-
RT classReader = createReader(abBytes);
105+
RT classReader = createReader(abBytes, m_cOffset, m_cLength);
92106

93107
if (fRevertVersion)
94108
{
@@ -144,4 +158,18 @@ protected static int getMajorVersion(final byte[] abBytes)
144158
* The class bytes.
145159
*/
146160
protected byte[] m_abBytes;
161+
162+
/**
163+
* The offset within {@link #m_abBytes} the class starts.
164+
*
165+
* @since 25.03.1
166+
*/
167+
protected int m_cOffset;
168+
169+
/**
170+
* The total number of bytes of the class.
171+
*
172+
* @since 25.03.1
173+
*/
174+
protected int m_cLength;
147175
}

prj/coherence-json/src/main/java/com/oracle/coherence/io/json/genson/reflect/ASMCreatorParameterNameResolver.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
*
44
* Copyright 2011-2014 Genson - Cepoi Eugen
55
*
@@ -34,7 +34,7 @@
3434
* This class uses ASM library to resolve method and constructor parameter names from debug symbols
3535
* generated during compilation. Most libraries are compiled with debug symbols so in most cases
3636
* this class will be able to resolve them. It's pretty cool as you do not need to annotate the
37-
* parameters anymore! However be careful if you decide to use this feature, you must ensure that
37+
* parameters anymore! However, be careful if you decide to use this feature, you must ensure that
3838
* your software is compiled with debug symbols for production! That's why this feature is disabled
3939
* by default. To enable it :
4040
* <p/>
@@ -367,12 +367,20 @@ public ClassReaderInternal(byte[] abBytes)
367367
super(abBytes);
368368
}
369369

370+
/**
371+
* @see BaseClassReaderInternal#BaseClassReaderInternal(byte[], int, int)
372+
*/
373+
public ClassReaderInternal(byte[] abBytes, int cOffset, int cLength)
374+
{
375+
super(abBytes, cOffset, cLength);
376+
}
377+
370378
// ----- BaseClassReaderInternal methods --------------------------------
371379

372380
@Override
373-
protected ClassReader createReader(byte[] abBytes)
381+
protected ClassReader createReader(byte[] abBytes, int cOffset, int cLength)
374382
{
375-
return new ClassReader(abBytes);
383+
return new ClassReader(abBytes, cOffset, cLength);
376384
}
377385

378386
@Override

prj/coherence-rest/src/main/java/com/tangosol/coherence/rest/util/PartialObject.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -733,12 +733,20 @@ public ClassReaderInternal(byte[] abBytes)
733733
super(abBytes);
734734
}
735735

736+
/**
737+
* @see BaseClassReaderInternal#BaseClassReaderInternal(byte[], int, int)
738+
*/
739+
public ClassReaderInternal(byte[] abBytes, int cOffset, int cLength)
740+
{
741+
super(abBytes, cOffset, cLength);
742+
}
743+
736744
// ----- BaseClassReaderInternal methods --------------------------------
737745

738746
@Override
739-
protected ClassReader createReader(byte[] abBytes)
747+
protected ClassReader createReader(byte[] abBytes, int cOffset, int cLength)
740748
{
741-
return new ClassReader(abBytes);
749+
return new ClassReader(abBytes, cOffset, cLength);
742750
}
743751

744752
@Override

0 commit comments

Comments
 (0)