question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Whitebox.setInternalState for private static final fields

See original GitHub issue

Hello,

Can you please add the ability for Whitebox.setInternalState to be invokable on classes with private static final field?

Whitebox.setInternalState(ClassToTest.class, "LOG", mockLog);

I did not understand where is the best place to add a feature request. I hope this is the best place.

Thank you

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marcingrzejszczakcommented, Jun 7, 2016

So I can assume that we can close this

1reaction
marcingrzejszczakcommented, May 31, 2016

Hi! Why would you even want to do that? It sounds like a absolutely terrible idea to do that. Can you provide some use case?

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerMock testing - set static field of class - Stack Overflow
Whitebox.setInternalState(Foo.class, b);. Works as long as you set a non-null value, and if theres only one field with the class of B ....
Read more >
Whitebox.setInternalState doesn't work with final properties?
Hi, I need to assign a mock to a private static final field, and was under the impression that Whitebox.setInternalState would handle that....
Read more >
Whitebox (powermock-reflect 1.6.3 API) - javadoc.io
setInternalState. public static void setInternalState(Object object, String fieldName, Object value). Set the value of a field using reflection. This method ...
Read more >
org.powermock.reflect.Whitebox.setInternalState java code ...
Useful for testing classes with a private constructor. getType · getFields. Get an array of Field's that matches the supplied list of field...
Read more >
whitebox.setinternalstate use
you are trying to set a private static final string. cannot set such fields! When accessing primitive static final fields, the Java compiler...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found