Skip to content

Commit

Permalink
fix: Mark Java HybridObjectRegistry as deprecated (#491)
Browse files Browse the repository at this point in the history
* fix: Mark Java `HybridObjectRegistry` as deprecated

HybridObjects should be registered from C++ instead.

* Update JHybridObjectRegistry.hpp

* Update JHybridObjectRegistry.hpp

* fix: Better warning
  • Loading branch information
mrousavy authored Jan 13, 2025
1 parent bbbeeaf commit ad29b24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct JHybridObjectRegistry : public jni::JavaClass<JHybridObjectRegistry> {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/HybridObjectRegistry;";

public:
[[deprecated("HybridObjects should be registered from C++ instead. Either autolink them using `nitro.json`, "
"or add them manually in the C++ HybridObjectRegistry.")]]
static void registerHybridObjectConstructor(jni::alias_ref<jni::JClass> clazz, std::string hybridObjectName,
jni::alias_ref<JHybridObjectInitializer> constructorFn);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

import com.facebook.proguard.annotations.DoNotStrip;

/**
* @deprecated HybridObjects should be registered from C++ instead. Either autolink them using `nitro.json`, or add them manually in the C++ `HybridObjectRegistry`.
*/
@Keep
@DoNotStrip
@Deprecated(forRemoval = true)
public interface HybridObjectInitializer {
@Keep
@DoNotStrip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class HybridObjectRegistry {
* Registers the given HybridObject in the `HybridObjectRegistry`.
* It will be uniquely identified via it's `hybridObjectName`, and can be initialized from
* JS using `NitroModules.createHybridObject<T>(name)` - which will call the `constructorFn` here.
* @deprecated HybridObjects should be registered from C++ instead. Either autolink them using `nitro.json`, or add them manually in the C++ `HybridObjectRegistry`.
*/
@Deprecated(forRemoval = true)
public static native void registerHybridObjectConstructor(String hybridObjectName, HybridObjectInitializer initializer);
}

0 comments on commit ad29b24

Please sign in to comment.