-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide GraalVM metadata and substitutions (#1357)
- Loading branch information
Showing
20 changed files
with
357 additions
and
529 deletions.
There are no files selected for viewing
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
bson/src/main/resources/META-INF/native-image/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"name":"java.lang.Object", | ||
"queryAllDeclaredMethods":true | ||
}, | ||
{ | ||
"name":"sun.security.provider.NativePRNG", | ||
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"<init>","parameterTypes":["java.security.SecureRandomParameters"] }] | ||
}, | ||
{ | ||
"name":"sun.security.provider.SHA", | ||
"methods":[{"name":"<init>","parameterTypes":[] }] | ||
}, | ||
{ | ||
"name":"org.slf4j.Logger" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ore/src/main/com/mongodb/internal/graalvm/substitution/UnixServerAddressSubstitution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.mongodb.internal.graalvm.substitution; | ||
|
||
import com.mongodb.UnixServerAddress; | ||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
|
||
@TargetClass(UnixServerAddress.class) | ||
public final class UnixServerAddressSubstitution { | ||
@Substitute | ||
private static void checkNotInGraalVmNativeImage() { | ||
throw new UnsupportedOperationException("UnixServerAddress is not supported in GraalVM native image"); | ||
} | ||
|
||
private UnixServerAddressSubstitution() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
driver-core/src/main/resources/META-INF/native-image/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
[ | ||
{ | ||
"name":"com.mongodb.BasicDBObject", | ||
"methods":[{"name":"<init>","parameterTypes":[] }] | ||
}, | ||
{ | ||
"name":"com.mongodb.MongoNamespace", | ||
"allDeclaredFields":true, | ||
"queryAllDeclaredMethods":true, | ||
"queryAllDeclaredConstructors":true | ||
}, | ||
{ | ||
"name":"com.mongodb.WriteConcern", | ||
"allPublicFields":true | ||
}, | ||
{ | ||
"name":"com.mongodb.client.model.changestream.ChangeStreamDocument", | ||
"allDeclaredFields":true, | ||
"queryAllDeclaredMethods":true, | ||
"queryAllDeclaredConstructors":true, | ||
"methods":[{"name":"<init>","parameterTypes":["java.lang.String","org.bson.BsonDocument","org.bson.BsonDocument","org.bson.BsonDocument","java.lang.Object","java.lang.Object","org.bson.BsonDocument","org.bson.BsonTimestamp","com.mongodb.client.model.changestream.UpdateDescription","org.bson.BsonInt64","org.bson.BsonDocument","org.bson.BsonDateTime","com.mongodb.client.model.changestream.SplitEvent","org.bson.BsonDocument"] }] | ||
}, | ||
{ | ||
"name":"com.mongodb.client.model.changestream.SplitEvent", | ||
"allDeclaredFields":true, | ||
"queryAllDeclaredMethods":true, | ||
"queryAllDeclaredConstructors":true | ||
}, | ||
{ | ||
"name":"com.mongodb.client.model.changestream.TruncatedArray", | ||
"allDeclaredFields":true, | ||
"queryAllDeclaredMethods":true, | ||
"queryAllDeclaredConstructors":true | ||
}, | ||
{ | ||
"name":"com.mongodb.client.model.changestream.UpdateDescription", | ||
"allDeclaredFields":true, | ||
"queryAllDeclaredMethods":true, | ||
"queryAllDeclaredConstructors":true, | ||
"methods":[{"name":"<init>","parameterTypes":["java.util.List","org.bson.BsonDocument","java.util.List","org.bson.BsonDocument"] }] | ||
}, | ||
{ | ||
"name":"java.lang.Record" | ||
}, | ||
{ | ||
"name":"java.lang.Thread", | ||
"fields":[{"name":"threadLocalRandomProbe"}] | ||
}, | ||
{ | ||
"name":"java.net.Socket", | ||
"methods":[{"name":"setOption","parameterTypes":["java.net.SocketOption","java.lang.Object"] }] | ||
}, | ||
{ | ||
"name":"java.security.SecureRandomParameters" | ||
}, | ||
{ | ||
"name":"java.util.concurrent.ForkJoinTask", | ||
"fields":[{"name":"aux"}, {"name":"status"}] | ||
}, | ||
{ | ||
"name":"java.util.concurrent.atomic.Striped64", | ||
"fields":[{"name":"base"}, {"name":"cellsBusy"}] | ||
}, | ||
{ | ||
"name":"jdk.internal.misc.Unsafe" | ||
}, | ||
{ | ||
"name":"jdk.net.ExtendedSocketOptions", | ||
"fields":[{"name":"TCP_KEEPCOUNT"}, {"name":"TCP_KEEPIDLE"}, {"name":"TCP_KEEPINTERVAL"}] | ||
}, | ||
{ | ||
"name":"org.bson.codecs.kotlin.DataClassCodecProvider" | ||
}, | ||
{ | ||
"name":"org.bson.codecs.kotlinx.KotlinSerializerCodecProvider" | ||
}, | ||
{ | ||
"name":"org.bson.codecs.record.RecordCodecProvider" | ||
}, | ||
{ | ||
"name":"org.slf4j.Logger" | ||
} | ||
] |
2 changes: 2 additions & 0 deletions
2
driver-core/src/main/resources/META-INF/native-image/resource-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
graalvm-native-image-app/src/main/com/mongodb/internal/graalvm/CustomDnsClientProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.mongodb.internal.graalvm; | ||
|
||
import com.mongodb.internal.dns.JndiDnsClient; | ||
import com.mongodb.spi.dns.DnsClient; | ||
import com.mongodb.spi.dns.DnsClientProvider; | ||
import com.mongodb.spi.dns.DnsException; | ||
|
||
import java.util.List; | ||
|
||
import static java.lang.String.format; | ||
|
||
public final class CustomDnsClientProvider implements DnsClientProvider { | ||
private static volatile boolean used = false; | ||
|
||
public CustomDnsClientProvider() { | ||
} | ||
|
||
@Override | ||
public DnsClient create() { | ||
return new CustomDnsClient(); | ||
} | ||
|
||
static void assertUsed() throws AssertionError { | ||
if (!used) { | ||
throw new AssertionError(format("%s is not used", CustomDnsClientProvider.class.getSimpleName())); | ||
} | ||
} | ||
|
||
private static void markUsed() { | ||
used = true; | ||
} | ||
|
||
private static final class CustomDnsClient implements DnsClient { | ||
private final JndiDnsClient wrapped; | ||
|
||
CustomDnsClient() { | ||
wrapped = new JndiDnsClient(); | ||
} | ||
|
||
@Override | ||
public List<String> getResourceRecordData(final String name, final String type) throws DnsException { | ||
markUsed(); | ||
return wrapped.getResourceRecordData(name, type); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.