Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <j9build@ca.ibm.com>
  • Loading branch information
j9build committed Aug 24, 2024
2 parents 7e10358 + 45bbb58 commit 12ee8ca
Show file tree
Hide file tree
Showing 51 changed files with 396 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, 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
Expand Down Expand Up @@ -40,7 +40,7 @@
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public interface AttributeMapper<A> {
public interface AttributeMapper<A extends Attribute<A>> {

/**
* Attribute stability indicator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
* ClassReader, int)} method for mapping from the classfile format
* to an attribute instance, and the
* {@link java.lang.classfile.AttributeMapper#writeAttribute(java.lang.classfile.BufWriter,
* java.lang.Object)} method for mapping back to the classfile format. It also
* java.lang.classfile.Attribute)} method for mapping back to the classfile format. It also
* contains metadata including the attribute name, the set of classfile entities
* where the attribute is applicable, and whether multiple attributes of the
* same kind are allowed on a single entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void writeTo(BufWriterImpl buf) {
}

@SuppressWarnings("unchecked")
<A> A get(AttributeMapper<A> am) {
<A extends Attribute<A>> A get(AttributeMapper<A> am) {
for (Attribute<?> a : attributes)
if (a.attributeMapper() == am)
return (A)a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static List<Attribute<?>> readAttributes(AttributedElement enclosing, Cla
mapper = customAttributes.apply(name);
}
if (mapper != null) {
filled.add((Attribute<?>) Objects.requireNonNull(mapper.readAttribute(enclosing, reader, p)));
filled.add(Objects.requireNonNull(mapper.readAttribute(enclosing, reader, p)));
} else {
AttributeMapper<UnknownAttribute> fakeMapper = new AttributeMapper<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static MethodTypeDesc methodTypeSymbol(NameAndTypeEntry nat) {
}

@SuppressWarnings("unchecked")
private static <T> void writeAttribute(BufWriterImpl writer, Attribute<?> attr) {
private static <T extends Attribute<T>> void writeAttribute(BufWriterImpl writer, Attribute<?> attr) {
if (attr instanceof CustomAttribute<?> ca) {
var mapper = (AttributeMapper<T>) ca.attributeMapper();
mapper.writeAttribute(writer, (T) ca);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, 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
Expand Down Expand Up @@ -427,13 +427,15 @@ public boolean isPreempted() {
* Pins the current continuation (enters a critical section).
* This increments an internal semaphore that, when greater than 0, pins the continuation.
*/
@IntrinsicCandidate
public static native void pin();

/**
* Unpins the current continuation (exits a critical section).
* This decrements an internal semaphore that, when equal 0, unpins the current continuation
* if pinned with {@link #pin()}.
*/
@IntrinsicCandidate
public static native void unpin();

/**
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@
jdk.internal.jvmstat,
jdk.management,
jdk.management.agent,
jdk.internal.vm.ci;
jdk.internal.vm.ci,
jdk.jfr;
exports jdk.internal.vm.annotation to
java.instrument,
jdk.internal.vm.ci,
Expand Down
23 changes: 13 additions & 10 deletions src/java.base/unix/classes/sun/nio/ch/FileKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -33,15 +33,18 @@
*/
public class FileKey {

private long st_dev; // ID of device
private long st_ino; // Inode number
private final long st_dev; // ID of device
private final long st_ino; // Inode number

private FileKey() { }
private FileKey(long st_dev, long st_ino) {
this.st_dev = st_dev;
this.st_ino = st_ino;
}

public static FileKey create(FileDescriptor fd) throws IOException {
FileKey fk = new FileKey();
fk.init(fd);
return fk;
long finfo[] = new long[2];
init(fd, finfo);
return new FileKey(finfo[0], finfo[1]);
}

@Override
Expand All @@ -59,10 +62,10 @@ public boolean equals(Object obj) {
&& (this.st_ino == other.st_ino);
}

private native void init(FileDescriptor fd) throws IOException;
private static native void initIDs();
private static native void init(FileDescriptor fd, long[] finfo)
throws IOException;

static {
initIDs();
IOUtil.load();
}
}
24 changes: 8 additions & 16 deletions src/java.base/unix/native/libnio/ch/FileKey.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,21 @@
#include "nio_util.h"
#include "sun_nio_ch_FileKey.h"

static jfieldID key_st_dev; /* id for FileKey.st_dev */
static jfieldID key_st_ino; /* id for FileKey.st_ino */


JNIEXPORT void JNICALL
Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz)
{
CHECK_NULL(key_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J"));
CHECK_NULL(key_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J"));
}


JNIEXPORT void JNICALL
Java_sun_nio_ch_FileKey_init(JNIEnv *env, jobject this, jobject fdo)
Java_sun_nio_ch_FileKey_init(JNIEnv* env, jclass clazz, jobject fdo,
jlongArray finfo)
{
struct stat fbuf;
int res;
jlong deviceAndInode[2];

RESTARTABLE(fstat(fdval(env, fdo), &fbuf), res);
int fd = fdval(env, fdo);
RESTARTABLE(fstat(fd, &fbuf), res);
if (res < 0) {
JNU_ThrowIOExceptionWithLastError(env, "fstat failed");
} else {
(*env)->SetLongField(env, this, key_st_dev, (jlong)fbuf.st_dev);
(*env)->SetLongField(env, this, key_st_ino, (jlong)fbuf.st_ino);
deviceAndInode[0] = (jlong)fbuf.st_dev;
deviceAndInode[1] = (jlong)fbuf.st_ino;
(*env)->SetLongArrayRegion(env, finfo, 0, 2, deviceAndInode);
}
}
24 changes: 14 additions & 10 deletions src/java.base/windows/classes/sun/nio/ch/FileKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@
*/
public class FileKey {

private int dwVolumeSerialNumber;
private int nFileIndexHigh;
private int nFileIndexLow;
private final int dwVolumeSerialNumber;
private final int nFileIndexHigh;
private final int nFileIndexLow;

private FileKey() { }
private FileKey(int dwVolumeSerialNumber, int nFileIndexHigh,
int nFileIndexLow) {
this.dwVolumeSerialNumber = dwVolumeSerialNumber;
this.nFileIndexHigh = nFileIndexHigh;
this.nFileIndexLow = nFileIndexLow;
}

public static FileKey create(FileDescriptor fd) throws IOException {
FileKey fk = new FileKey();
fk.init(fd);
return fk;
int finfo[] = new int[3];
init(fd, finfo);
return new FileKey(finfo[0], finfo[1], finfo[2]);
}

@Override
Expand All @@ -60,11 +65,10 @@ public boolean equals(Object obj) {
&& this.nFileIndexLow == other.nFileIndexLow;
}

private native void init(FileDescriptor fd) throws IOException;
private static native void initIDs();
private static native void init(FileDescriptor fd, int[] finfo)
throws IOException;

static {
IOUtil.load();
initIDs();
}
}
28 changes: 8 additions & 20 deletions src/java.base/windows/native/libnio/ch/FileKey.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -30,32 +30,20 @@
#include "nio_util.h"
#include "sun_nio_ch_FileKey.h"

static jfieldID key_volumeSN; /* id for FileKey.dwVolumeSerialNumber */
static jfieldID key_indexHigh; /* id for FileKey.nFileIndexHigh */
static jfieldID key_indexLow; /* id for FileKey.nFileIndexLow */


JNIEXPORT void JNICALL
Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz)
{
CHECK_NULL(key_volumeSN = (*env)->GetFieldID(env, clazz, "dwVolumeSerialNumber", "I"));
CHECK_NULL(key_indexHigh = (*env)->GetFieldID(env, clazz, "nFileIndexHigh", "I"));
CHECK_NULL(key_indexLow = (*env)->GetFieldID(env, clazz, "nFileIndexLow", "I"));
}


JNIEXPORT void JNICALL
Java_sun_nio_ch_FileKey_init(JNIEnv *env, jobject this, jobject fdo)
Java_sun_nio_ch_FileKey_init(JNIEnv *env, jclass clazz, jobject fdo, jintArray finfo)
{
HANDLE fileHandle = (HANDLE)(handleval(env, fdo));
HANDLE fileHandle = (HANDLE)handleval(env, fdo);
BOOL result;
BY_HANDLE_FILE_INFORMATION fileInfo;
jint info[3];

result = GetFileInformationByHandle(fileHandle, &fileInfo);
if (result) {
(*env)->SetIntField(env, this, key_volumeSN, fileInfo.dwVolumeSerialNumber);
(*env)->SetIntField(env, this, key_indexHigh, fileInfo.nFileIndexHigh);
(*env)->SetIntField(env, this, key_indexLow, fileInfo.nFileIndexLow);
info[0] = (jint)fileInfo.dwVolumeSerialNumber;
info[1] = (jint)fileInfo.nFileIndexHigh;
info[2] = (jint)fileInfo.nFileIndexLow;
(*env)->SetIntArrayRegion(env, finfo, 0, 3, info);
} else {
JNU_ThrowIOExceptionWithLastError(env, "GetFileInformationByHandle failed");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand All @@ -25,10 +25,8 @@

package javax.annotation.processing;

import javax.tools.JavaFileManager;
import javax.tools.*;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

package javax.lang.model;

import java.util.Collections;
import java.util.Set;
import java.util.HashSet;

/**
* Source versions of the Java programming language.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -27,8 +27,6 @@


import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.util.List;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand All @@ -25,8 +25,6 @@

package javax.lang.model.element;

import jdk.internal.javac.PreviewFeature;

import java.util.List;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand All @@ -25,8 +25,6 @@

package javax.lang.model.element;

import jdk.internal.javac.PreviewFeature;

import javax.lang.model.util.Elements;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeKind;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand Down Expand Up @@ -28,8 +28,6 @@

import javax.lang.model.element.Element;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.util.Types;


/**
* Represents a type variable.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, 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
Expand All @@ -25,7 +25,6 @@

package javax.lang.model.type;

import javax.lang.model.element.*;
import javax.lang.model.util.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import jdk.internal.javac.PreviewFeature;

import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
import javax.annotation.processing.SupportedSourceVersion;
import javax.annotation.processing.ProcessingEnvironment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

import javax.annotation.processing.SupportedSourceVersion;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.ElementVisitor;
import javax.lang.model.element.RecordComponentElement;
import static javax.lang.model.SourceVersion.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package javax.lang.model.util;

import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.type.*;
import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;

Expand Down
Loading

0 comments on commit 12ee8ca

Please sign in to comment.