undefined grapghics method using JRubyApplet instance - jruby

I get the following error using the JRubyApplet instance:
*Exception in thread "AWT-EventQueue-1"
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method
'drawString' for Java::SunJava2D::SunGraphics2D*
with the following script.rb :
include Java
JRUBY_APPLET.on_paint do |g|
g.drawString("hello",0,0)
end
I have not succeed to puts any elements from AWT/Graphics
I guess my code is wrong but I don't know where.

Related

assertEquals throws a NullPointerException, but equals method does not

I have two list objects and want to check that the first items of each are equal. However, I get a NullPointerException at this line:
assertEquals(instance.getPlane(0), planes.get(0));
This is the entire stack trace:
Testcase: testGetPlane(mypackage.PlaneTest): Caused an ERROR
null
java.lang.NullPointerException
at mypackage.PlaneTest.testGetPlane(PlaneTest.java:60)
(Line 60 is the assertion.)
Neither of those objects are null. I'm having a separate issue getting the debugger to work, so instead I added these printouts to my test case:
System.err.println("equals? " + instance.getPlane(0).equals(planes.get(0)));
System.err.println("equals? " + planes.get(0).equals(instance.getPlane(0)));
However, those lines executed without throwing any errors!
I've cleaned and built the project and restarted Netbeans, but still have this issue.
JUnit just calls expected.equals(actual), which should be exactly the same thing as my printouts that aren't throwing the error, right? Why would assertEquals throw a NullPointerException, but equals on the same objects would not?
(I was about to post the question alone when I discovered the fix, but since it was a pain I'm posting it anyways in hopes this may help someone else. I did not find any other questions which had this solution.)
The error is in fact caused by JUnit, when it tries to compose an error message.
In the format function, there are the lines:
String expectedString = String.valueOf(expected);
String actualString = String.valueOf(actual);
if (expectedString.equals(actualString)) { ... }
String.valueOf(Object obj) returns obj.toString() if obj is not null.
My object's toString method simply returned a "name" field, which was never set inside the test. So, the object was not null, but the function returned null. This caused the NullPointerException when JUnit tried to call expectedString.equals. Ensuring that toString never returns null fixed the error.

a session error after updating to laravel 5.4

After updating from laravel 5.3 to 5.4, I encountered an error in vendor. The error is:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Session\Store::set() in /var/www/ostadbank.com/vendor/laravel/framework/src/Illuminate/Support/Manager.php:137
But when I go to my error is:
fatal error exception in Manager.php line 137:call to undefined method Illuminate\session\store::set()
I go to manager.php line 137 and I see the line below:
public function __call($method, $parameters) { return $this->driver()->$method(...$parameters); }
I am not sure where to start to modify.
See the screenshots below:
I solve it, for more information read this: https://laravel.com/docs/5.4/upgrade
All calls to the ->set() method should be changed to ->put(). Typically, Laravel applications would never call the set method since it has never been documented within the Laravel documentation. However, it is included here out of caution.

How long is a line after a readline(fh, line) call?

I have written a JSON parser in VHDL. The parser core uses two nested loops:
1. loop over all lines until EOF
2. loop over every char until line of end
For clearance: Its not a hardware parser. the parser used to read synthesis settings at synthesis time to configure instantiated entities like a baudrate in a UART module.)
The inner loop looks like this: loopj : for j in CurrentLine.all'range loop
Source: JSON.pkg.vhdl
This code works in XST 14.7, iSim 14.7 and GHDL, but not in Vivado. Vivado does not support .all. The error message is this one:
ERROR: [Synth 8-27] access type dereference not supported [D:/git/GitHub/JSON-for-VHDL/vhdl/JSON.pkg.vhdl:293]
Updated code, due to the hint from kraigher:
#Paebbles Have you tried foo'range instead of foo.all'range? I think I remember that it should implicitly work. - kraigher
I tried it before, but got an error. Maybe this error was related to another one. Now its working. So my current loopj line looks like this:
loopj : for j in CurrentLine'range loop
This line works fine in XST, iSim, GHDL and QuestaSim, but Vivado still has problems:
INFO: [Synth 8-638] synthesizing module 'Boards2' [.../Boards2.vhdl:16]
ERROR: [Synth 8-278] expression 0 out of range [.../JSON.pkg.vhdl:293]
ERROR: [Synth 8-421] mismatched array sizes in rhs and lhs of assignment [.../Boards2.vhdl:20]
ERROR: [Synth 8-285] failed synthesizing module 'Boards2' [.../Boards2.vhdl:16]
How can a expression be out of range? This message is very strange.
Is there another way to get a range for a loop, depending on how long the current line is?

Fetching Error Code in mule

I want to create a custom exception message in case exception is thrown by my mule service. In order to do that, i want to separately capture mule generated ErrorCode. Is there any property using which i can get that value? I tried using #[org.mule.config.ExceptionHelper.getErrorCode(Exception.class)]" but this returned -1 as a value instead of the actual exception code.
What method can i use to fetch ErrorCode?
You are supposed to pass the class of the current exception, ie:
#[org.mule.config.ExceptionHelper.getErrorCode(exception.class)]"
exception is the current exception while Exception is the java.lang.Exception class for which there is no error code associated.

What Does This Ember Exception Mean?

I'm getting the following error when creating a new record/model:
Uncaught Error: Attempted to handle event `willSetProperty` on <App.NewsItem:ember361:null> while in state rootState.loaded.created.inFlight. Called with {reference: [object Object], store: <App.Store:ember299>, name: bodyHTML}
What does it mean?
Seems to be caused by the application updating a property (called 'bodyHTML') on an instance of a model of type App.NewsItem while it is being saved (rootState.loaded.created.inFlight). I have no idea why I'm receiving the error on creation though.
Seems like either you are modifying an existing dirty object , or you are trying setting some property to undefined
see
http://coryforsyth.com/2013/06/10/the-willsetproperty-gotcha-in-ember-data-understanding-the-state-machine/