Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
4ed215f
Enable DD JDK integration tests
jbachorik Jun 21, 2023
cdf915e
Merge branch 'upstream-master'
Jun 21, 2023
eac40e2
Merge branch 'upstream-master'
Jun 22, 2023
4b96877
Merge branch 'upstream-master'
Jun 23, 2023
3f7172a
Merge branch 'upstream-master'
Jun 24, 2023
5ab1610
Merge branch 'upstream-master'
Jun 26, 2023
4ad86bd
Merge branch 'upstream-master'
Jun 27, 2023
069e812
Merge branch 'upstream-master'
Jun 28, 2023
db99501
Merge branch 'upstream-master'
Jun 29, 2023
0009f6e
Merge branch 'upstream-master'
Jun 30, 2023
9860489
Merge branch 'upstream-master'
Jul 1, 2023
c166cc6
Merge branch 'upstream-master'
Jul 2, 2023
6892063
Merge branch 'upstream-master'
Jul 3, 2023
78fe42e
Merge branch 'upstream-master'
Jul 4, 2023
71591a6
Merge branch 'upstream-master'
Jul 5, 2023
226e410
Merge branch 'upstream-master'
Jul 6, 2023
3403988
Merge branch 'upstream-master'
Jul 7, 2023
76478fb
Merge branch 'upstream-master'
Jul 8, 2023
e57fec0
Merge branch 'upstream-master'
Jul 10, 2023
3aec829
Merge branch 'upstream-master'
Jul 11, 2023
01df99b
Merge branch 'upstream-master'
Jul 12, 2023
e8c4a07
Merge branch 'upstream-master'
Jul 13, 2023
d62c1c2
Merge branch 'upstream-master'
Jul 14, 2023
aa1729d
Merge branch 'upstream-master'
Jul 15, 2023
f158a81
Merge branch 'upstream-master'
Jul 16, 2023
7030bcb
Merge branch 'upstream-master'
Jul 17, 2023
50236f7
Merge branch 'upstream-master'
Jul 18, 2023
6ac7f17
Merge branch 'upstream-master'
Jul 19, 2023
3d651b7
Merge branch 'upstream-master'
Jul 20, 2023
5ab33fa
Merge branch 'upstream-master'
Jul 21, 2023
c0039a7
Merge branch 'upstream-master'
Jul 22, 2023
fa28f52
Merge branch 'upstream-master'
Jul 23, 2023
a3517cb
Merge branch 'upstream-master'
Jul 24, 2023
1038c07
Merge branch 'upstream-master'
Jul 25, 2023
8ab4463
Merge branch 'upstream-master'
Jul 26, 2023
8f07835
Merge branch 'upstream-master'
Jul 27, 2023
25c9398
Merge branch 'upstream-master'
Jul 28, 2023
f5f5540
Merge branch 'upstream-master'
Jul 29, 2023
303b38a
Merge branch 'upstream-master'
Jul 31, 2023
275d648
Merge branch 'upstream-master'
Aug 1, 2023
4ceb59f
Merge branch 'upstream-master'
Aug 2, 2023
d4cddf1
Merge branch 'upstream-master'
Aug 3, 2023
776ae18
Merge branch 'upstream-master'
Aug 4, 2023
50ecba3
Merge branch 'upstream-master'
Aug 5, 2023
b3d9191
Merge branch 'upstream-master'
Aug 7, 2023
11471ca
Merge branch 'upstream-master'
Aug 8, 2023
f2bacab
Merge branch 'upstream-master'
Aug 9, 2023
84d4f83
Merge branch 'upstream-master'
Aug 10, 2023
9f4458d
Merge branch 'upstream-master'
Aug 11, 2023
65b2afa
Merge branch 'upstream-master'
Aug 12, 2023
2eee387
Merge branch 'upstream-master'
Aug 14, 2023
aefbccf
Merge branch 'upstream-master'
Aug 15, 2023
37aa13d
Merge branch 'upstream-master'
Aug 16, 2023
7f5c369
Merge branch 'upstream-master'
Aug 17, 2023
602137c
Merge branch 'upstream-master'
Aug 18, 2023
43d8d6e
Merge branch 'upstream-master'
Aug 19, 2023
b72635b
Merge branch 'upstream-master'
Aug 20, 2023
6d6c28b
Merge branch 'upstream-master'
Aug 21, 2023
bd9deab
Merge branch 'upstream-master'
Aug 22, 2023
3e2d6aa
Merge branch 'upstream-master'
Aug 23, 2023
ea87110
Merge branch 'upstream-master'
Aug 24, 2023
721de0a
Merge branch 'upstream-master'
Aug 25, 2023
3ea7eb4
Merge branch 'upstream-master'
Aug 26, 2023
581240c
Merge branch 'upstream-master'
Aug 27, 2023
629f34f
Merge branch 'upstream-master'
Aug 28, 2023
f208dd2
Merge branch 'upstream-master'
Aug 29, 2023
f3f5234
Merge branch 'upstream-master'
Aug 30, 2023
6af39bc
Merge branch 'upstream-master'
Aug 31, 2023
044cf30
Merge branch 'upstream-master'
Sep 1, 2023
11c788a
Merge branch 'upstream-master'
Sep 2, 2023
165e717
Merge branch 'upstream-master'
Sep 4, 2023
1ec9254
Merge branch 'upstream-master'
Sep 5, 2023
3a8f48f
Merge branch 'upstream-master'
Sep 6, 2023
30f6241
Merge branch 'upstream-master'
Sep 7, 2023
6c3d179
Merge branch 'upstream-master'
Sep 8, 2023
52825ab
Merge branch 'upstream-master'
Sep 9, 2023
f8479dc
Merge branch 'upstream-master'
Sep 11, 2023
22f045b
Merge branch 'upstream-master'
Sep 12, 2023
816b1c6
Merge branch 'upstream-master'
Sep 13, 2023
456b3fe
Merge branch 'upstream-master'
Sep 14, 2023
c50cfd3
Merge branch 'upstream-master'
Sep 15, 2023
1c92d73
Merge branch 'upstream-master'
Sep 16, 2023
0682b7a
Merge branch 'upstream-master'
Sep 17, 2023
a46ef37
Merge branch 'upstream-master'
Sep 18, 2023
be1b63c
Merge branch 'upstream-master'
Sep 19, 2023
6a06ea9
Merge branch 'upstream-master'
Sep 20, 2023
b6328de
Merge branch 'upstream-master'
Sep 21, 2023
5fea71f
Merge branch 'upstream-master'
Sep 22, 2023
2b1d9a6
Merge branch 'upstream-master'
Sep 23, 2023
0d5037b
Merge branch 'upstream-master'
Sep 25, 2023
3ef4f03
Merge branch 'upstream-master'
Sep 26, 2023
40e8b17
Merge branch 'upstream-master'
Sep 27, 2023
45ef5bd
Merge branch 'upstream-master'
Sep 28, 2023
3fbea63
Merge branch 'upstream-master'
Sep 29, 2023
05e8a22
Merge branch 'upstream-master'
Sep 30, 2023
4919852
Merge branch 'upstream-master'
Oct 2, 2023
df4892d
Merge branch 'upstream-master'
Oct 3, 2023
63257ae
Merge branch 'upstream-master'
Oct 4, 2023
e35338a
Merge branch 'upstream-master'
Oct 5, 2023
31eecdf
Merge branch 'upstream-master'
Oct 6, 2023
9844f26
Merge branch 'upstream-master'
Oct 7, 2023
475eced
Merge branch 'upstream-master'
Oct 8, 2023
75bd0bd
Merge branch 'upstream-master'
Oct 9, 2023
0d37f05
Merge branch 'upstream-master'
Oct 10, 2023
e4b2941
Merge branch 'upstream-master'
Oct 11, 2023
19b8f24
Merge branch 'upstream-master'
Oct 12, 2023
2629626
Merge branch 'upstream-master'
Oct 13, 2023
9c71c3d
Merge branch 'upstream-master'
Oct 14, 2023
281b87d
Merge branch 'upstream-master'
Oct 15, 2023
6b5c393
Merge branch 'upstream-master'
Oct 16, 2023
a23e667
Merge branch 'upstream-master'
Oct 17, 2023
097b4f5
Merge branch 'upstream-master'
Oct 18, 2023
4fc1932
Merge branch 'upstream-master'
Oct 19, 2023
85f9121
Merge branch 'upstream-master'
Oct 20, 2023
006ff9d
Merge branch 'upstream-master'
Oct 21, 2023
2895835
Merge branch 'upstream-master'
Oct 22, 2023
a45208b
Merge branch 'upstream-master'
Oct 23, 2023
8292c8b
Merge branch 'upstream-master'
Oct 24, 2023
7a1b294
Merge branch 'upstream-master'
Oct 25, 2023
bbf8e17
Merge branch 'upstream-master'
Oct 26, 2023
33be2a4
Merge branch 'upstream-master'
Oct 27, 2023
41144fa
Merge branch 'upstream-master'
Oct 28, 2023
9be978b
Merge branch 'upstream-master'
Oct 29, 2023
45be238
Merge branch 'upstream-master'
Oct 30, 2023
52652b7
Merge branch 'upstream-master'
Oct 31, 2023
1e0bf6b
Merge branch 'upstream-master'
Nov 1, 2023
a9e649a
Merge branch 'upstream-master'
Nov 2, 2023
81faeb2
Merge branch 'upstream-master'
Nov 3, 2023
5fd93d1
Merge branch 'upstream-master'
Nov 4, 2023
97dd113
Merge branch 'upstream-master'
Nov 5, 2023
ab59c9c
Merge branch 'upstream-master'
Nov 6, 2023
d78eff0
Merge branch 'upstream-master'
Nov 7, 2023
a7dd7ae
Merge branch 'upstream-master'
Nov 8, 2023
ec6a1df
Merge branch 'upstream-master'
Nov 9, 2023
a4723ad
Merge branch 'upstream-master'
Nov 10, 2023
ff21baf
Merge branch 'upstream-master'
Nov 11, 2023
e7b4eba
Merge branch 'upstream-master'
Nov 13, 2023
00d74e4
Merge branch 'upstream-master'
Nov 14, 2023
c09ac6b
Merge branch 'upstream-master'
Nov 15, 2023
ff69781
Merge branch 'upstream-master'
Nov 16, 2023
cb35689
Merge branch 'upstream-master'
Nov 17, 2023
671a8ee
Merge branch 'upstream-master'
Nov 18, 2023
3431263
Merge branch 'upstream-master'
Nov 20, 2023
9ee38ac
Merge branch 'upstream-master'
Nov 21, 2023
b40f661
Merge branch 'upstream-master'
Nov 22, 2023
a86b7ac
Merge branch 'upstream-master'
Nov 23, 2023
98020bf
Merge branch 'upstream-master'
Nov 24, 2023
d70d859
Merge branch 'upstream-master'
Nov 25, 2023
cea75b5
Merge branch 'upstream-master'
Nov 27, 2023
35ac477
Merge branch 'upstream-master'
Nov 28, 2023
04195d4
Merge branch 'upstream-master'
Nov 29, 2023
8444396
Merge branch 'upstream-master'
Nov 30, 2023
ba8789d
Merge branch 'upstream-master'
Dec 1, 2023
3086466
Merge branch 'upstream-master'
Dec 2, 2023
7ad4457
Merge branch 'upstream-master'
Dec 3, 2023
4e2975e
Merge branch 'upstream-master'
Dec 4, 2023
9f1c1f8
Absorb JDK-8054435 JEP prototype
jbachorik Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/dd-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# .github/workflows/sync-upstream.yml
name: Sync Upstream

on:
schedule:
- cron: '22 14 * * *' # Runs every day at 14:15 UTC
workflow_dispatch:

jobs:
sync:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0

- name: Pull latest changes from upstream
run: |
git config --global user.email "[email protected]"
git config --global user.name "Datadog Syncup Service"
git remote add upstream https://github.com/openjdk/jdk.git
git fetch upstream
git checkout -b upstream-master upstream/master
git checkout master
git merge upstream-master

- name: Push changes to downstream
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_PAT }}
branch: master
30 changes: 30 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
image: alpine

stages: [trigger]

build:
stage: trigger
variables:
JDK_VERSION: "22"
DEBUG_LEVEL: "fastdebug"
HASH: "${CI_COMMIT_SHORT_SHA}"
trigger:
project: DataDog/openjdk-build
strategy: depend
branch: main
forward:
pipeline_variables: true

test:
stage: trigger
needs: [build]
variables:
JDK_VERSION: "22"
DEBUG_LEVEL: "fastdebug"
HASH: "${CI_COMMIT_SHORT_SHA}"
trigger:
project: DataDog/apm-reliability/async-profiler-build
strategy: depend
branch: main
forward:
pipeline_variables: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.jmx.annotations;

import com.sun.jmx.annotations.model.AttributeModel;
import com.sun.jmx.annotations.model.MXBeanModel;
import com.sun.jmx.annotations.model.OperationModel;
import com.sun.jmx.annotations.model.InjectableFieldModel;
import com.sun.jmx.mbeanserver.DynamicMBean2;
import com.sun.jmx.mbeanserver.MXBeanMapping;
import com.sun.jmx.mbeanserver.MXBeanMappingFactory;

import java.io.InvalidObjectException;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.IntrospectionException;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ReflectionException;
import javax.management.annotations.NotificationSender;
import javax.management.annotations.NotificationInfos;
import javax.management.modelmbean.ModelMBeanNotificationInfo;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;


/**
* A wrapper for the annotated MBeans. For the purposes of cooperation with
* the rest of the JMX system the annotated MBean will behave like a
* {@linkplain DynamicMBean2} and {@linkplain NotificationEmitter} instance.
*
*/
abstract class AnnotatedMBean<T> implements DynamicMBean2, NotificationEmitter, NotificationSender {
protected final MXBeanModel<T> model;
protected final T instance;
private NotificationBroadcasterSupport nbs = null;
private final MBeanInfoBuilder mib;

protected AnnotatedMBean(MXBeanModel<T> model, T instance) throws IntrospectionException {
this.model = model;
this.instance = instance;
this.mib = new MBeanInfoBuilder(model.getMappingFactory());
injectFields();
}

private void injectFields() throws IntrospectionException {
for(InjectableFieldModel fm : model.getInjectableFields()) {
if (fm.getType().isAssignableFrom(NotificationSender.class)) {
// inject the NotificationSender instances
fm.inject(instance, this);
}
}
}

private synchronized NotificationBroadcasterSupport getNbs() {
if (nbs == null) {
List<ModelMBeanNotificationInfo> ntfs = model.getNotifications().stream()
.map(mib::toNotificationInfo).collect(Collectors.toList());
nbs = new NotificationBroadcasterSupport(ntfs.toArray(new ModelMBeanNotificationInfo[ntfs.size()]));
}
return nbs;
}

@Override
public Object getResource() {
return this;
}

@Override
public String getClassName() {
return model.getName();
}

@Override
public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException {
try {
AttributeModel mam = model.getAttribute(attribute);
if (mam == null) {
throw new AttributeNotFoundException("Can not find attribute '" + attribute + "'");
}
MXBeanMapping m = getMapping(mam.getType());
MethodHandle h = mam.getGetter().bindTo(instance);

Object[] args = new Object[h.type().parameterCount()];
Class<?>[] paramTypes = h.type().parameterArray();
for(int i=0;i<args.length;i++) {
if (NotificationSender.class.isAssignableFrom(paramTypes[i])) {
args[i] = this;
}
}
Object val = args.length > 0 ? h.invokeWithArguments(args) : h.invoke();

return m != null ? m.toOpenValue(val) : val;
} catch (Throwable t) {
throw new MBeanException((Exception) t);
}
}

@Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
try {
AttributeModel mam = model.getAttribute(attribute.getName());
if (mam == null) {
throw new AttributeNotFoundException();
}
MXBeanMapping m = getMapping(mam.getType());
MethodHandle h = mam.getSetter().bindTo(instance);
Object[] args = new Object[h.type().parameterCount()];
Class<?>[] paramTypes = h.type().parameterArray();
for(int i=0;i<args.length;i++) {
if (paramTypes[i].equals(NotificationSender.class)) {
h = h.bindTo(this);
} else {
h = h.bindTo(m != null ? m.fromOpenValue(attribute.getValue()) : attribute.getValue());
}
}
h.invoke();
} catch (Throwable t) {
throw new MBeanException((Exception) t);
}
}

@Override
public AttributeList getAttributes(String[] attributes) {
AttributeList al = new AttributeList(attributes.length);
for(String aName : attributes) {
try {
Object val = getAttribute(aName);
al.add(new Attribute(aName, val));
} catch (AttributeNotFoundException | MBeanException | ReflectionException ex) {
// just ignore; method signature does not allow for exceptions
}
}
return al;
}

@Override
public AttributeList setAttributes(AttributeList attributes) {
AttributeList setAttrs = new AttributeList(attributes.size());
for (Attribute a : attributes.asList()) {
try {
setAttribute(a);
setAttrs.add(a);
} catch (AttributeNotFoundException | MBeanException |
ReflectionException | InvalidAttributeValueException ex) {
// just ignore; method signature does not allow for exceptions
}
}
return setAttrs;
}

@Override
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException {
unwrapCompositeTypes(params, signature);

String type = Arrays.asList(signature).stream().collect(Collectors.joining(", ", "(", ")"));
try {
OperationModel mom = model.getOperation(actionName, type);
if (mom == null) {
throw new MBeanException(null, "Unknown operation: " + actionName);
}
MXBeanMapping m = getMapping(mom.getType());

MethodHandle mh = mom.getMethodHandle().bindTo(instance);

java.lang.reflect.Parameter[] mParams = mom.getMethod().getParameters();
Object[] transParams = new Object[mom.getMethod().getParameterCount()];

for(int pIndex = 0, tIndex = 0;tIndex<transParams.length;tIndex++) {
if (NotificationSender.class.isAssignableFrom(mParams[tIndex].getType()) && (
mParams[tIndex].isAnnotationPresent(NotificationInfos.class) ||
mParams[tIndex].isAnnotationPresent(javax.management.annotations.NotificationInfo.class))) {
transParams[tIndex] = this;
} else {
java.lang.reflect.Parameter p = mParams[tIndex];
MXBeanMapping map = getMapping(p.getType());
Object val = params[pIndex++];
transParams[tIndex] = map != null ? map.fromOpenValue(val) : val;
}
}

Object val = mh.invokeWithArguments(transParams);
return m != null ? m.toOpenValue(val) : val;
} catch (OpenDataException | InvalidObjectException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new MBeanException(e);
} catch (Throwable t) {
throw new MBeanException(new InvocationTargetException(t));
}
}

@Override
public MBeanInfo getMBeanInfo() {
return mib.toMBeanInfo(model);
}

@Override
final public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) {
getNbs().addNotificationListener(listener, filter, handback);
}

@Override
final public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
getNbs().removeNotificationListener(listener);
}

@Override
final public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
getNbs().removeNotificationListener(listener, filter, handback);
}

@Override
final public MBeanNotificationInfo[] getNotificationInfo() {
return getNbs().getNotificationInfo();
}

@Override
final public void sendNotification(Notification notification) {
getNbs().sendNotification(notification);
}

private final AtomicLong notifCounter = new AtomicLong();

@Override
public void sendNotification(String type, String message, Object userData) {
Notification n = new Notification(type, this, notifCounter.getAndIncrement(), message);
n.setUserData(userData);
nbs.sendNotification(n);
}

private MXBeanMapping getMapping(Class<?> type) throws OpenDataException {
return model.getMappingFactory().mappingForType(type, MXBeanMappingFactory.DEFAULT);
}

private void unwrapCompositeTypes(Object[] params, String[] signature) {
if (params != null) {
for(int i=0;i<params.length;i++) {
if (signature[i].equals(CompositeData.class.getName())) {
CompositeType ct = ((CompositeData)params[i]).getCompositeType();
signature[i] = ct.getTypeName();
}
}
}
}
}
Loading
Loading