Category "reflection"

Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute (CS0579)

I am creating a .Net core project using VS Community V 8.10.2 on my Macbook air. I created a parent .Net Core MVC project and created multiple class library pro

How to register services with dependency container services by reflection in c#

I have an interface IProcessor and multiple processors implementing this interface: Processor1 : IProcessor Processor2 : IProcessor I want to inject these proc

Get name of function using reflection

I'm trying to use Go's reflection system to retrieve the name of a function but I get an empty string when calling the Name method on its type. Is this the expe

How to check if a class has overriden a default method from an interface using Reflection in Kotlin or Java?

I have an interface with a default method, and two classes which implement this interface. One of the classes overrides the default method, and the other does n

How to check an empty object?

I have a number of objects. Some of them have string properties and some of them have bool properties. I'm using them in multi-step form. so each step is bound

ByteBuddy Agent to print method elapsed time

I'm trying to measure the time for certains method of some specific classes. I'm using ByteBuddy and I created the following interceptor class: public class Ti

How to use .NET reflection to check for nullable reference type

C# 8.0 introduces nullable reference types. Here's a simple class with a nullable property: public class Foo { public String? Bar { get; set; } } Is ther

Is it possible to set private static final field using Reflection in JDK 17 [duplicate]

I am trying to upgrade my application Java version from v1.8 to v17. There are some unit tests which are using Reflection to set value of priv

How to call private functions of a class from outside the class in Kotlin

I want to call a private functions of class SomeClass from outside of this class: class SomeClass { private fun somePrivateFunction() { //... }

java Field change listener

So I would really want some way of detecting Field changes of a certain object. I have googled for quite a while but haven't found anything. So basically all I

Get declared fields of java.lang.reflect.Fields in jdk12

In java8 it was possible to access fields of class java.lang.reflect.Fields using e.g. Field.class.getDeclaredFields(); In java12 (starting with java9 ?) thi

Using reflection to identify if the error thrown matches expected error

I need to write a simple code tester program, but I got stuck comparing the given error class with the test expected class. I am supposed to use reflection in t

How to solve InaccessibleObjectException ("Unable to make {member} accessible: module {A} does not 'opens {package}' to {B}") on Java 9?

This exception occurs in a wide variety of scenarios when running an application on Java 9. Certain libraries and frameworks (Spring, Hibernate, JAXB) are parti

Storing field of struct accessed via reflection

I am picking up quest parameters for my game from a CSV. The parameters include a stat tracked, e.g. "CardsDeployed", and conditions for what kind of cards are

I want to detect if a JVM Class is a Kotlin class or not

I want to do special functionality if I encounter a Kotlin class as compared to a generic Java class. How can I detect if it is a Kotlin class? I was hoping

Create empty array using reflection [duplicate]

How do I create empty array of a type given by reflection? I have tried using the Activator.CreateInstance(Type) method: Type arrayType = typ

Using reflection to set object properties without using setValue forKey

In Swift it's not possible use .setValue(..., forKey: ...) nullable type fields like Int? properties that have an enum as it's type an Array of nullable objec

Automatically delegating all methods of a java class

Say I have a class with many of public methods: public class MyClass { public void method1() {} public void method2() {} (...) public void met

How to programmatically find public properties of a class from inside one of it's methods

I've got a class Foo with public and protected properties. Foo needs to have a non-static method, getPublicVars() that returns a list of all the public propert

Php, reflection, how to remove "final" declaration?

I want to test a class which is declared: "final class testme" and cannot be mocked. How to remove the "final" keyword with reflections?