Skip to content

Commit e8d1e39

Browse files
[jnigen] Add regression tests for native/#693 and clean up TODOs (#2283)
1 parent 6db256e commit e8d1e39

File tree

5 files changed

+292
-13
lines changed

5 files changed

+292
-13
lines changed

pkgs/jnigen/test/jackson_core_test/generate.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,6 @@ Config getConfig({
5757
'com.fasterxml.jackson.core.JsonToken',
5858
],
5959
logLevel: Level.INFO,
60-
exclude: BindingExclusions(
61-
// TODO(#31): Remove field exclusions.
62-
fields: excludeAll<Field>([
63-
['com.fasterxml.jackson.core.JsonFactory', 'DEFAULT_QUOTE_CHAR'],
64-
['com.fasterxml.jackson.core.Base64Variant', 'PADDING_CHAR_NONE'],
65-
['com.fasterxml.jackson.core.base.ParserMinimalBase', 'CHAR_NULL'],
66-
['com.fasterxml.jackson.core.io.UTF32Reader', 'NC'],
67-
]),
68-
// TODO(#159): Remove class exclusions.
69-
classes: ClassNameFilter.exclude(
70-
'com.fasterxml.jackson.core.JsonFactoryBuilder',
71-
),
72-
),
7360
);
7461
return config;
7562
}

pkgs/jnigen/test/simple_package_test/bindings/simple_package.dart

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13731,3 +13731,275 @@ final class $R2250$Type<$T extends jni$_.JObject?>
1373113731
T == other.T;
1373213732
}
1373313733
}
13734+
13735+
/// from: `com.github.dart_lang.jnigen.regressions.R693$Child`
13736+
class R693$Child extends R693<R693$Child?> {
13737+
@jni$_.internal
13738+
@core$_.override
13739+
final jni$_.JObjType<R693$Child> $type;
13740+
13741+
@jni$_.internal
13742+
R693$Child.fromReference(
13743+
jni$_.JReference reference,
13744+
) : $type = type,
13745+
super.fromReference(const $R693$Child$NullableType(), reference);
13746+
13747+
static final _class = jni$_.JClass.forName(
13748+
r'com/github/dart_lang/jnigen/regressions/R693$Child');
13749+
13750+
/// The type which includes information such as the signature of this class.
13751+
static const nullableType = $R693$Child$NullableType();
13752+
static const type = $R693$Child$Type();
13753+
static final _id_new$ = _class.constructorId(
13754+
r'()V',
13755+
);
13756+
13757+
static final _new$ = jni$_.ProtectedJniExtensions.lookup<
13758+
jni$_.NativeFunction<
13759+
jni$_.JniResult Function(
13760+
jni$_.Pointer<jni$_.Void>,
13761+
jni$_.JMethodIDPtr,
13762+
)>>('globalEnv_NewObject')
13763+
.asFunction<
13764+
jni$_.JniResult Function(
13765+
jni$_.Pointer<jni$_.Void>,
13766+
jni$_.JMethodIDPtr,
13767+
)>();
13768+
13769+
/// from: `public void <init>()`
13770+
/// The returned object must be released after use, by calling the [release] method.
13771+
factory R693$Child() {
13772+
return R693$Child.fromReference(
13773+
_new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr)
13774+
.reference);
13775+
}
13776+
}
13777+
13778+
final class $R693$Child$NullableType extends jni$_.JObjType<R693$Child?> {
13779+
@jni$_.internal
13780+
const $R693$Child$NullableType();
13781+
13782+
@jni$_.internal
13783+
@core$_.override
13784+
String get signature =>
13785+
r'Lcom/github/dart_lang/jnigen/regressions/R693$Child;';
13786+
13787+
@jni$_.internal
13788+
@core$_.override
13789+
R693$Child? fromReference(jni$_.JReference reference) => reference.isNull
13790+
? null
13791+
: R693$Child.fromReference(
13792+
reference,
13793+
);
13794+
@jni$_.internal
13795+
@core$_.override
13796+
jni$_.JObjType get superType =>
13797+
const $R693$NullableType<R693$Child?>($R693$Child$NullableType());
13798+
13799+
@jni$_.internal
13800+
@core$_.override
13801+
jni$_.JObjType<R693$Child?> get nullableType => this;
13802+
13803+
@jni$_.internal
13804+
@core$_.override
13805+
final superCount = 2;
13806+
13807+
@core$_.override
13808+
int get hashCode => ($R693$Child$NullableType).hashCode;
13809+
13810+
@core$_.override
13811+
bool operator ==(Object other) {
13812+
return other.runtimeType == ($R693$Child$NullableType) &&
13813+
other is $R693$Child$NullableType;
13814+
}
13815+
}
13816+
13817+
final class $R693$Child$Type extends jni$_.JObjType<R693$Child> {
13818+
@jni$_.internal
13819+
const $R693$Child$Type();
13820+
13821+
@jni$_.internal
13822+
@core$_.override
13823+
String get signature =>
13824+
r'Lcom/github/dart_lang/jnigen/regressions/R693$Child;';
13825+
13826+
@jni$_.internal
13827+
@core$_.override
13828+
R693$Child fromReference(jni$_.JReference reference) =>
13829+
R693$Child.fromReference(
13830+
reference,
13831+
);
13832+
@jni$_.internal
13833+
@core$_.override
13834+
jni$_.JObjType get superType =>
13835+
const $R693$NullableType<R693$Child?>($R693$Child$NullableType());
13836+
13837+
@jni$_.internal
13838+
@core$_.override
13839+
jni$_.JObjType<R693$Child?> get nullableType =>
13840+
const $R693$Child$NullableType();
13841+
13842+
@jni$_.internal
13843+
@core$_.override
13844+
final superCount = 2;
13845+
13846+
@core$_.override
13847+
int get hashCode => ($R693$Child$Type).hashCode;
13848+
13849+
@core$_.override
13850+
bool operator ==(Object other) {
13851+
return other.runtimeType == ($R693$Child$Type) && other is $R693$Child$Type;
13852+
}
13853+
}
13854+
13855+
/// from: `com.github.dart_lang.jnigen.regressions.R693`
13856+
class R693<$T extends jni$_.JObject?> extends jni$_.JObject {
13857+
@jni$_.internal
13858+
@core$_.override
13859+
final jni$_.JObjType<R693<$T>> $type;
13860+
13861+
@jni$_.internal
13862+
final jni$_.JObjType<$T> T;
13863+
13864+
@jni$_.internal
13865+
R693.fromReference(
13866+
this.T,
13867+
jni$_.JReference reference,
13868+
) : $type = type<$T>(T),
13869+
super.fromReference(reference);
13870+
13871+
static final _class =
13872+
jni$_.JClass.forName(r'com/github/dart_lang/jnigen/regressions/R693');
13873+
13874+
/// The type which includes information such as the signature of this class.
13875+
static $R693$NullableType<$T> nullableType<$T extends jni$_.JObject?>(
13876+
jni$_.JObjType<$T> T,
13877+
) {
13878+
return $R693$NullableType<$T>(
13879+
T,
13880+
);
13881+
}
13882+
13883+
static $R693$Type<$T> type<$T extends jni$_.JObject?>(
13884+
jni$_.JObjType<$T> T,
13885+
) {
13886+
return $R693$Type<$T>(
13887+
T,
13888+
);
13889+
}
13890+
13891+
static final _id_new$ = _class.constructorId(
13892+
r'()V',
13893+
);
13894+
13895+
static final _new$ = jni$_.ProtectedJniExtensions.lookup<
13896+
jni$_.NativeFunction<
13897+
jni$_.JniResult Function(
13898+
jni$_.Pointer<jni$_.Void>,
13899+
jni$_.JMethodIDPtr,
13900+
)>>('globalEnv_NewObject')
13901+
.asFunction<
13902+
jni$_.JniResult Function(
13903+
jni$_.Pointer<jni$_.Void>,
13904+
jni$_.JMethodIDPtr,
13905+
)>();
13906+
13907+
/// from: `public void <init>()`
13908+
/// The returned object must be released after use, by calling the [release] method.
13909+
factory R693({
13910+
required jni$_.JObjType<$T> T,
13911+
}) {
13912+
return R693<$T>.fromReference(
13913+
T,
13914+
_new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr)
13915+
.reference);
13916+
}
13917+
}
13918+
13919+
final class $R693$NullableType<$T extends jni$_.JObject?>
13920+
extends jni$_.JObjType<R693<$T>?> {
13921+
@jni$_.internal
13922+
final jni$_.JObjType<$T> T;
13923+
13924+
@jni$_.internal
13925+
const $R693$NullableType(
13926+
this.T,
13927+
);
13928+
13929+
@jni$_.internal
13930+
@core$_.override
13931+
String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R693;';
13932+
13933+
@jni$_.internal
13934+
@core$_.override
13935+
R693<$T>? fromReference(jni$_.JReference reference) => reference.isNull
13936+
? null
13937+
: R693<$T>.fromReference(
13938+
T,
13939+
reference,
13940+
);
13941+
@jni$_.internal
13942+
@core$_.override
13943+
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
13944+
13945+
@jni$_.internal
13946+
@core$_.override
13947+
jni$_.JObjType<R693<$T>?> get nullableType => this;
13948+
13949+
@jni$_.internal
13950+
@core$_.override
13951+
final superCount = 1;
13952+
13953+
@core$_.override
13954+
int get hashCode => Object.hash($R693$NullableType, T);
13955+
13956+
@core$_.override
13957+
bool operator ==(Object other) {
13958+
return other.runtimeType == ($R693$NullableType<$T>) &&
13959+
other is $R693$NullableType<$T> &&
13960+
T == other.T;
13961+
}
13962+
}
13963+
13964+
final class $R693$Type<$T extends jni$_.JObject?>
13965+
extends jni$_.JObjType<R693<$T>> {
13966+
@jni$_.internal
13967+
final jni$_.JObjType<$T> T;
13968+
13969+
@jni$_.internal
13970+
const $R693$Type(
13971+
this.T,
13972+
);
13973+
13974+
@jni$_.internal
13975+
@core$_.override
13976+
String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R693;';
13977+
13978+
@jni$_.internal
13979+
@core$_.override
13980+
R693<$T> fromReference(jni$_.JReference reference) => R693<$T>.fromReference(
13981+
T,
13982+
reference,
13983+
);
13984+
@jni$_.internal
13985+
@core$_.override
13986+
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
13987+
13988+
@jni$_.internal
13989+
@core$_.override
13990+
jni$_.JObjType<R693<$T>?> get nullableType => $R693$NullableType<$T>(T);
13991+
13992+
@jni$_.internal
13993+
@core$_.override
13994+
final superCount = 1;
13995+
13996+
@core$_.override
13997+
int get hashCode => Object.hash($R693$Type, T);
13998+
13999+
@core$_.override
14000+
bool operator ==(Object other) {
14001+
return other.runtimeType == ($R693$Type<$T>) &&
14002+
other is $R693$Type<$T> &&
14003+
T == other.T;
14004+
}
14005+
}

pkgs/jnigen/test/simple_package_test/generate.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ final javaFiles = [
5555
join(javaPrefix, 'interfaces', 'StringConverterConsumer.java'),
5656
join(javaPrefix, 'pkg2', 'C2.java'),
5757
join(javaPrefix, 'pkg2', 'Example.java'),
58+
join(javaPrefix, 'regressions', 'R693.java'),
5859
join(javaPrefix, 'regressions', 'R2250.java'),
5960
join(javaPrefix, 'simple_package', 'Example.java'),
6061
join(javaPrefix, 'simple_package', 'Exceptions.java'),

pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/regressions/R2250.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package com.github.dart_lang.jnigen.regressions;
66

7+
// Regression test for https://github.com/dart-lang/native/issues/2250.
78
public interface R2250<T> {
89
public void foo(T t);
910

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
package com.github.dart_lang.jnigen.regressions;
6+
7+
// Regression test for https://github.com/dart-lang/native/issues/693.
8+
public class R693<T extends R693<T>> {
9+
T foo() {
10+
return null;
11+
}
12+
13+
public static class Child extends R693<Child> {
14+
Child foo() {
15+
return new Child();
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)