Questions tagged [introspection]

A capability of some object-oriented programming languages to determine the type of an object at runtime.

Some OOP languages providing Type Introspection ability : Ruby, Objective-C, C++, Java, PHP, Perl, Python, Object Pascal, Actionscript (as3)

The introspection is done differently, depending on the form of program, it is performed upon: inspecting a source code or compiled byte-code is called compile-time introspection, while inspecting properties of running code is a run-time introspection.

For example, Java supports both types of introspection: users of run-time introspection typically perform it via , while compile-time introspection can be implemented with tools or .

http://en.wikipedia.org/wiki/Type_introspection

1021 questions
0
votes
2 answers

How to turn these functions generic

I wanted to shorten my code, since i`m having more functions like this. I was wondering if I could use getattr() to do something like this guy asked. Well, here it goes what I`ve got: def getAllMarkersFrom(db, asJSON=False): '''Gets all markers…
cesarvargas
  • 182
  • 3
  • 15
0
votes
1 answer

Introspector finding properties that no longer exist

I'm relying on introspection for XML processing in a Java EE 6 app I've been working on for quite a while. So far it has worked just fine. However, I had to rename a property setter name. The problem is, Introspector.getBeanInfo(Class) is…
Steve
  • 8,066
  • 11
  • 70
  • 112
0
votes
2 answers

java introspection to find member of the class

I'm trying to access the attribute of an Object object through its name memberName. I tried: new PropertyDescriptor(memberName,object.getClass()).getReadMethod().invoke(object); It works well for most of the attributes of my Object. But some of…
Car981
  • 261
  • 1
  • 3
  • 11
0
votes
6 answers

Given a Collection get the type of the items (Java)

I need to get the type of the item of a collection. For retrieving the class of a single instance I use the following code: classUnderTest.getName() But, how can I retrieve the class of the items of the following collection? Collection collection =…
cloudy_weather
  • 2,837
  • 12
  • 38
  • 63
0
votes
1 answer

How to get the name of an class statically in php?

With this code:
Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236
0
votes
1 answer

Introspection of a Map

I am trying to develop some utility code which is portable to both the J2SE and the Android platforms for the caching of objects. The plan is to extract an abstract class when I get it working, but for now it is part of the final class…
Dobbo
  • 1,188
  • 3
  • 16
  • 27
0
votes
1 answer

Python / PySide / Qt: Find out a signals name inside a slot

Using the pyside qt binding module inside a small python 2.7 project I want to find out the source of a signal. So inside a slot I want to have some means to ask by what signal this slot has actually been triggered with. I figured out that this…
arkascha
  • 41,620
  • 7
  • 58
  • 90
0
votes
2 answers

"Cannot be cast to java.lang.Class", namely: which type is not a class

This may seem a dumb question (as it could be very project specific) but in this case it's general enough: I'm running a piece of code which gives the ClassCastException, with the error message I wrote as title. Here the mentioned cast is from an…
Dacav
  • 13,590
  • 11
  • 60
  • 87
0
votes
1 answer

How can I create a new object of the same class as an object I already have?

I've an array which holds different kinds of objects: UIButtons, UILabels, UITableViews, etc. Is there any way that I can dynamically create these objects while looping through the array without using if/else conditions like below: for (NSObject…
0
votes
2 answers

Importing Gtk object from gi.repository

Back in my GTK2 days, I could do a from gtk import Clipboard To get access to the clipboard from my program. Now days, we must import objects introspectively as in: from gi.repository import Gtk I have been scratching my head to see if there is a…
narnie
  • 1,742
  • 1
  • 18
  • 34
0
votes
1 answer

Python Introspection: Defining dynamic class methods during runtime

I'm trying to create a unit test, that checks that every function in mymodule has its own TestCase instance. To reduce boiler-plate code and manual effort I wanted to use introspection/reflection to dynamically add lambda functions as class methods…
Chris
  • 1,613
  • 1
  • 18
  • 27
0
votes
1 answer

How to introspect Java Web Start GUI Application?

There is an Java Web Start GUI Application. As I understand it is based on Swing. So the question is how to make an introspection in that application? Is there any way to accomplish that? For example, in case of HTML there is a Firebug application…
amigo
  • 343
  • 5
  • 19
0
votes
0 answers

Why does phpsh not show structured information about variables?

I have just installed phpsh shell as described here: http://vocecommunications.com/blog/2010/12/how-to-setup-an-interactive-wordpress-shell/ Normally, the shell should show introspection of returned variables as here: php> =…
Mert Nuhoglu
  • 9,695
  • 16
  • 79
  • 117
0
votes
1 answer

Introspection in Java

I have a stack of Objects, in this stack I push ClassA and ClassB objects. I have a method which must return objects from this stack public Object method(Stack s){ ClassA a = new ClassA(); stack.push(a); ClassB b = new ClassB(); …
AR89
  • 3,548
  • 7
  • 31
  • 46
0
votes
3 answers

Introspection on the Object to print attribute

I grabbed this piece of code: ClassABC abc = new ClassABC(); for (Field field : abc.getClass().getDeclaredFields()) { field.setAccessible(true); String name = field.getName(); Object value = field.get(abc); System.out.printf("Field…
Will
  • 8,246
  • 16
  • 60
  • 92