Project

General

Profile

« Previous | Next » 

Revision 7a1fcbeb

Added by Leszek Koltunski about 5 years ago

fix a bug: in certain places when we use reflection, it needs to be getDeclaredMethod and not getMethod because the methods are not public!

View differences:

src/main/java/org/distorted/library/effect/Effect.java
40 40
  private final int mRegionDim;
41 41
  private final int mCenterDim;
42 42

  
43
  ArrayList<EffectListener> mListeners =null;
44
  int mNumListeners=0;  // ==mListeners.length(), but we only create mListeners if the first one gets added
43
  private ArrayList<EffectListener> mListeners =null;
44
  private int mNumListeners=0;  // ==mListeners.length(), but we only create mListeners if the first one gets added
45 45

  
46 46
  private static long mNextID = 0;
47 47

  
......
172 172
 */
173 173
  public static void enableEffects(EffectType type)
174 174
    {
175
    Method method=null;
175
    Method method;
176 176

  
177 177
    for(EffectName name: EffectName.values())
178 178
      {
......
182 182

  
183 183
        try
184 184
          {
185
          method = cls.getMethod("enable");
185
          method = cls.getMethod("enable");  // getMethod and NOT getDeclaredMethod because enable()
186
                                             // is public
186 187
          }
187 188
        catch(NoSuchMethodException ex)
188 189
          {
189 190
          android.util.Log.e("Effect", "exception getting method: "+ex.getMessage());
191
          method = null;
190 192
          }
191 193

  
192 194
        try
193 195
          {
194
          method.invoke(null);
196
          if( method!=null ) method.invoke(null);
195 197
          }
196 198
        catch(Exception ex)
197 199
          {
src/main/java/org/distorted/library/effect/PostprocessEffect.java
197 197
    mSources.clear();
198 198
    mNumSources = 0;
199 199

  
200
    Method method=null;
200
    Method method;
201 201

  
202 202
    for(EffectName name: EffectName.values())
203 203
      {
......
207 207

  
208 208
        try
209 209
          {
210
          method = cls.getMethod("destroyStatics");
210
          method = cls.getDeclaredMethod("destroyStatics");  // destroyStatics not public, thus getDeclaredMethod
211 211
          }
212 212
        catch(NoSuchMethodException ex)
213 213
          {
214
          android.util.Log.e("postprocess", "exception getting method: "+ex.getMessage());
214
          android.util.Log.e("postprocess", cls.getSimpleName()+": exception getting method: "+ex.getMessage());
215
          method = null;
215 216
          }
216 217

  
217 218
        try
218 219
          {
219
          method.invoke(null);
220
          if( method!=null ) method.invoke(null);
220 221
          }
221 222
        catch(Exception ex)
222 223
          {

Also available in: Unified diff