# forObject static method

Class<Object> forObject(

1. Object obj, [
2. ProtectionDomain? domain,
3. String? package

])

Creates a Class instance for an object's runtime type.

Parameters:

- `obj`: The object to reflect
- `domain`: Optional protection domain
- `package`: Optional package name to search with

Returns:

- A Class instance for the object's type

## Implementation

    static Class<Object> forObject(Object obj, [ProtectionDomain? domain, String? package]) {
      try {
        return Class.fromQualifiedName(ReflectionUtils.findQualifiedName(obj), domain ?? ProtectionDomain.system());
      } on ClassNotFoundException catch (_) {
        if(obj.runtimeType.toString().notEqualsIgnoreCase("type")) {
          return _Class<Object>(obj.runtimeType.toString(), domain ?? ProtectionDomain.current(), package);
        }

        return _Class<Object>(obj.toString(), domain ?? ProtectionDomain.current(), package);
      }
    }