Skip to content

Commit fd9415b

Browse files
[jnigen] Remove exclude from config (#2348)
Closes #2125
1 parent 9ef9699 commit fd9415b

File tree

25 files changed

+28
-197
lines changed

25 files changed

+28
-197
lines changed

pkgs/jnigen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.15.0-wip
2+
3+
- **Breaking Change**: Removed `exclude` from config.
4+
15
## 0.14.2
26

37
- The name `factory` can now also be used in a method name without renaming.

pkgs/jnigen/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ A `*` denotes required configuration.
250250
| `summarizer:` | (Subsection) | Configuration specific to summarizer component, which builds API descriptions from Java sources or JAR files. |
251251
| `summarizer:` >> `backend` | `auto`, `doclet` or `asm` | Specifies the backend to use in API summary generation. `doclet` uses OpenJDK Doclet API to build summary from sources. `asm` uses ASM library to build summary from classes in `class_path` JARs. `auto` attempts to find the class in sources, and falls back to using ASM. |
252252
| `summarizer:` >> `extra_args` (DEV) | List of CLI arguments | Extra arguments to pass to summarizer JAR. |
253-
| `exclude:` | (Subsection) | Exclude methods or fields using regex filters. It's generally useful to exclude problematic fields or methods which, with current binding generation, can lead to syntax errors |
254-
| `exclude:` >> `methods`| List of methods in `classBinaryName#methodName` format where classBinaryName is same as qualified name, but `$` preceding a nested class instead of `.`. Example: `com.example.MyClass` or `com.example.MyClass$NestedClass` | Methods to exclude.
255-
| `exclude:` >> `fields` | List of fields in `classBinaryName#fieldName` format | Fields to exclude.
256253
257254
It's possible to use the programmatic API instead of YAML.
258255

pkgs/jnigen/example/in_app_java/jnigen.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,3 @@ classes:
1414
- 'androidx.emoji2.text.DefaultEmojiCompatConfig' # From gradle's compile classpath
1515
- 'android.os.Build' # from gradle's compile classpath
1616
- 'java.util.HashMap' # from gradle's compile classpath
17-
exclude:
18-
fields:
19-
- 'android.os.Build\$VERSION_CODES#UPSIDE_DOWN_CAKE'

pkgs/jnigen/example/in_app_java/lib/android_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// ignore_for_file: annotate_overrides
44
// ignore_for_file: argument_type_not_assignable

pkgs/jnigen/example/kotlin_plugin/android/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ android {
2323
main.java.srcDirs += 'src/main/kotlin'
2424
}
2525

26+
kotlinOptions {
27+
jvmTarget = '11'
28+
}
29+
2630
compileOptions {
2731
sourceCompatibility JavaVersion.VERSION_11
2832
targetCompatibility JavaVersion.VERSION_11

pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// ignore_for_file: annotate_overrides
44
// ignore_for_file: argument_type_not_assignable

pkgs/jnigen/example/notification_plugin/lib/notifications.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
44
// for details. All rights reserved. Use of this source code is governed by a

pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocument.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Generated from Apache PDFBox library which is licensed under the Apache License 2.0.
44
// The following copyright from the original authors applies.

pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocumentInformation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Generated from Apache PDFBox library which is licensed under the Apache License 2.0.
44
// The following copyright from the original authors applies.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22
export 'PDDocument.dart';
33
export 'PDDocumentInformation.dart';

pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/PDFTextStripper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Generated from Apache PDFBox library which is licensed under the Apache License 2.0.
44
// The following copyright from the original authors applies.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22
export 'PDFTextStripper.dart';

pkgs/jnigen/lib/jnigen.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
library;
1313

1414
export 'src/config/config.dart';
15-
export 'src/config/filters.dart';
1615
export 'src/elements/elements.dart';
1716
export 'src/generate_bindings.dart';

pkgs/jnigen/lib/src/bindings/dart_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'visitor.dart';
1717
/// Version of jnigen. Keep in sync with `pubspec.yaml` removing the `-wip`
1818
/// suffix.
1919
@visibleForTesting
20-
const String version = '0.14.2';
20+
const String version = '0.15.0';
2121

2222
// Import prefixes.
2323
const _jni = r'jni$_';

pkgs/jnigen/lib/src/bindings/excluder.dart

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class Excluder extends Visitor<Classes, void> with TopLevelVisitor {
3737
@override
3838
void visit(Classes node) {
3939
node.decls.removeWhere((_, classDecl) {
40-
final excluded = classDecl.isPrivate ||
41-
classDecl.isExcluded ||
42-
!(config.exclude?.classes?.included(classDecl) ?? true);
40+
final excluded = classDecl.isPrivate || classDecl.isExcluded;
4341
if (excluded) {
4442
log.fine('Excluded class ${classDecl.binaryName}');
4543
}
@@ -69,13 +67,8 @@ class _ClassExcluder extends Visitor<ClassDecl, void> {
6967
final isPrivate = method.isPrivate;
7068
final isAbstractCtor = method.isConstructor && node.isAbstract;
7169
final isBridgeMethod = method.isSynthetic && method.isBridge;
72-
final isExcludedInConfig =
73-
config.exclude?.methods?.included(node, method) ?? false;
74-
final excluded = isPrivate ||
75-
isAbstractCtor ||
76-
isBridgeMethod ||
77-
isExcludedInConfig ||
78-
isExcluded;
70+
final excluded =
71+
isPrivate || isAbstractCtor || isBridgeMethod || isExcluded;
7972
if (excluded) {
8073
log.fine('Excluded method ${node.binaryName}#${method.name}');
8174
}
@@ -88,9 +81,7 @@ class _ClassExcluder extends Visitor<ClassDecl, void> {
8881
return !excluded;
8982
}).toList();
9083
node.fields = node.fields.where((field) {
91-
final excluded = field.isExcluded ||
92-
(field.isPrivate &&
93-
(config.exclude?.fields?.included(node, field) ?? true));
84+
final excluded = field.isExcluded || field.isPrivate;
9485
if (excluded) {
9586
log.fine('Excluded field ${node.binaryName}#${field.name}');
9687
}

pkgs/jnigen/lib/src/config/config_types.dart

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import '../logging/logging.dart';
1515
import '../util/find_package.dart';
1616
import 'config_exception.dart';
1717
import 'experiments.dart';
18-
import 'filters.dart';
1918
import 'yaml_reader.dart';
2019

2120
/// Modify this when symbols file format changes according to pub_semver.
@@ -234,13 +233,6 @@ class OutputConfig {
234233
SymbolsOutputConfig? symbolsConfig;
235234
}
236235

237-
class BindingExclusions {
238-
BindingExclusions({this.methods, this.fields, this.classes});
239-
MethodFilter? methods;
240-
FieldFilter? fields;
241-
ClassFilter? classes;
242-
}
243-
244236
bool _isCapitalized(String s) {
245237
final firstLetter = s.substring(0, 1);
246238
return firstLetter == firstLetter.toUpperCase();
@@ -270,7 +262,6 @@ class Config {
270262
{required this.outputConfig,
271263
required this.classes,
272264
this.experiments,
273-
this.exclude,
274265
this.sourcePath,
275266
this.classPath,
276267
this.preamble,
@@ -303,9 +294,6 @@ class Config {
303294

304295
Set<Experiment?>? experiments;
305296

306-
/// Methods and fields to be excluded from generated bindings.
307-
final BindingExclusions? exclude;
308-
309297
/// Paths to search for java source files.
310298
///
311299
/// If a source package is downloaded through [mavenDownloads] option,
@@ -483,24 +471,6 @@ class Config {
483471
return res;
484472
}
485473

486-
MemberFilter<T>? regexFilter<T extends ClassMember>(String property) {
487-
final exclusions = prov.getStringList(property);
488-
if (exclusions == null) return null;
489-
final filters = <MemberFilter<T>>[];
490-
for (var exclusion in exclusions) {
491-
final split = exclusion.split('#');
492-
if (split.length != 2) {
493-
throw ConfigException('Error parsing exclusion: "$exclusion": '
494-
'expected to be in binaryName#member format.');
495-
}
496-
filters.add(MemberNameFilter<T>.exclude(
497-
RegExp(split[0]),
498-
RegExp(split[1]),
499-
));
500-
}
501-
return CombinedMemberFilter<T>(filters);
502-
}
503-
504474
String? getSdkRoot() {
505475
final root = prov.getString(_Props.androidSdkRoot) ??
506476
Platform.environment['ANDROID_SDK_ROOT'];
@@ -529,10 +499,6 @@ class Config {
529499
backend: getSummarizerBackend(prov.getString(_Props.backend), null),
530500
workingDirectory: prov.getPath(_Props.summarizerWorkingDir),
531501
),
532-
exclude: BindingExclusions(
533-
methods: regexFilter<Method>(_Props.excludeMethods),
534-
fields: regexFilter<Field>(_Props.excludeFields),
535-
),
536502
outputConfig: OutputConfig(
537503
dartConfig: DartCodeOutputConfig(
538504
path: must(prov.getPath, Uri.parse('.'), _Props.dartRoot),
@@ -620,9 +586,6 @@ class _Props {
620586
static const sourcePath = 'source_path';
621587
static const classPath = 'class_path';
622588
static const classes = 'classes';
623-
static const exclude = 'exclude';
624-
static const excludeMethods = '$exclude.methods';
625-
static const excludeFields = '$exclude.fields';
626589

627590
static const experiments = 'enable_experiment';
628591
static const import = 'import';

pkgs/jnigen/lib/src/config/filters.dart

Lines changed: 0 additions & 118 deletions
This file was deleted.

pkgs/jnigen/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
name: jnigen
66
description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine.
77
# Keep in sync with `version` in `dart_generator.dart`.
8-
version: 0.14.2
8+
version: 0.15.0-wip
99
repository: https://github.com/dart-lang/native/tree/main/pkgs/jnigen
1010
issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ajnigen
1111

pkgs/jnigen/test/jackson_core_test/jnigen.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ classes:
1313
- 'com.fasterxml.jackson.core.JsonParser'
1414
- 'com.fasterxml.jackson.core.JsonToken'
1515

16-
exclude:
17-
fields:
18-
- 'com.fasterxml.jackson.core.JsonFactory#DEFAULT_QUOTE_CHAR'
19-
- 'com.fasterxml.jackson.core.Base64Variant#PADDING_CHAR_NONE'
20-
- 'com.fasterxml.jackson.core.base.ParserMinimalBase#CHAR_NULL'
21-
- 'com.fasterxml.jackson.core.io.UTF32Reader#NC'
2216

2317
preamble: |
2418
// Generated from jackson-core which is licensed under the Apache License 2.0.

pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonFactory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Generated from jackson-core which is licensed under the Apache License 2.0.
44
// The following copyright from the original authors applies.

pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonParser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Generated from jackson-core which is licensed under the Apache License 2.0.
44
// The following copyright from the original authors applies.

pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonToken.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Generated from jackson-core which is licensed under the Apache License 2.0.
44
// The following copyright from the original authors applies.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22
export 'JsonFactory.dart';
33
export 'JsonParser.dart';
44
export 'JsonToken.dart';

pkgs/jnigen/test/kotlin_test/bindings/kotlin.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
44
// for details. All rights reserved. Use of this source code is governed by a

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// AUTO GENERATED BY JNIGEN 0.14.2. DO NOT EDIT!
1+
// AUTO GENERATED BY JNIGEN 0.15.0. DO NOT EDIT!
22

33
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
44
// for details. All rights reserved. Use of this source code is governed by a

0 commit comments

Comments
 (0)