Skip to content

Commit dbf8afb

Browse files
committed
Prepare next release
1 parent 075ac83 commit dbf8afb

4 files changed

Lines changed: 28 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Elemento requires Java 17 now
13+
- Use JavaScript implementation to detect native JS objects in the logging module
14+
1015
### Upgrades
1116

1217
- Bump JBoss Parent to 50

logger/src/main/java/org/jboss/elemento/logger/Logger.java

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,9 @@
1818
import java.util.HashMap;
1919
import java.util.Map;
2020

21-
import elemental2.core.JsArray;
2221
import elemental2.core.JsDate;
23-
import elemental2.core.JsMap;
24-
import elemental2.core.JsRegExp;
25-
import elemental2.core.JsSet;
26-
import elemental2.core.JsWeakMap;
27-
import elemental2.core.JsWeakSet;
28-
import elemental2.dom.Event;
2922
import elemental2.dom.Location;
30-
import elemental2.dom.Node;
3123
import elemental2.dom.URLSearchParams;
32-
import elemental2.dom.Window;
3324
import jsinterop.annotations.JsMethod;
3425
import jsinterop.base.Js;
3526

@@ -513,34 +504,12 @@ private boolean jsNative(Object object) {
513504

514505
// Use Object.prototype.toString.call(obj) to get the internal [[Class]] property
515506
// This is a more reliable way to detect native JS objects
516-
String objectType = getObjectType(object);
507+
String objectType = objectType(object);
517508
return objectType.startsWith("[object ") &&
518509
!objectType.equals("[object Object]") &&
519510
!objectType.equals("[object Array]"); // Regular JS objects and arrays should be stringified
520511
}
521512

522-
@JsMethod(namespace = "Object.prototype.toString")
523-
private static native String call(Object obj);
524-
525-
private String getObjectType(Object obj) {
526-
try {
527-
return call(obj);
528-
} catch (Exception e) {
529-
// Fallback to the instanceof checks if the above method fails
530-
return isKnownNativeType(obj) ? "[object Native]" : "[object Object]";
531-
}
532-
}
533-
534-
private boolean isKnownNativeType(Object object) {
535-
return object instanceof JsArray ||
536-
object instanceof JsSet ||
537-
object instanceof JsMap ||
538-
object instanceof JsWeakSet ||
539-
object instanceof JsWeakMap ||
540-
object instanceof JsRegExp ||
541-
object instanceof JsDate ||
542-
object instanceof Event ||
543-
object instanceof Window ||
544-
object instanceof Node;
545-
}
513+
@JsMethod
514+
private static native String objectType(Object obj);
546515
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2023 Red Hat
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
function objectType(o) {
17+
const toString = Object.prototype.toString;
18+
return toString.call(o);
19+
}

router-processor/src/main/java/org/jboss/elemento/router/processor/RouteProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class RouteProcessor extends BasicAnnotationProcessor {
4040

4141
@Override
4242
public SourceVersion getSupportedSourceVersion() {
43-
return SourceVersion.RELEASE_11;
43+
return SourceVersion.RELEASE_17;
4444
}
4545

4646
@Override

0 commit comments

Comments
 (0)