hi every one
there is no way to get all static variable for program in memory
or ref of static variable to application by c# in memory by java
thanks for any help
解决方案
With .NET, this is easy, I suspect, with Java too.
Let me answer about .NET, which I know much better. All static variable are declared in classes or structures and not inside methods.
Consider you have the assembly of interest in memory (the one you obtain using System.Reflection.Assembly.GetAssembly, System.Reflection.Assembly.GetCallingAssembly, System.Reflection.Assembly.GetEntryAssembly or System.Reflection.Assembly.GetExecutingAssembly). For the assembly of interest, get all declared type using System.Assembly.GetType. Take all types, including private and non-private. For each type (skip enumeration files), get all static fields using System.Type.GetFields and parameter bindingFlags with the value System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic (these flags is the most important detail).
Now you have the list of all the static field members in the assembly. The type of the element of this list is System.Reflection.FieldInfo. Do not include members with the following predicate properties IsInitOnly == true (they are read-only). You don''t need to check predicate IsStatic, as non-static are already filtered out by the bindingFlags (see above). The problem is solved.
You can use the ideas to develop similar algorithm in Java — Java and C# Reflection designs are more or less similar.
—SA