How to get mock final classes mock-maker-inline to work? - mockito

I'm having issue getting the mock-maker-inline to work. I followed the instructions on
However, i still can't mock out a final class. I also tried out the example in the document. I was wondering if there is anyway to debug what went wrong?
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class Tests$1FinalClass
Mockito cannot mock/spy because :
- final class
I'm on mockito org.mockito:mockito-core:3.1.0 and using
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
Thanks,
Derek

Related

Is IBM Maximo 7.6 businessobject jar compiled in Java 1.8 compatible to run in java 1.7?

I have got jar compiled in java 1.8 from maximo dir and on my machine i have java 1.7 installed do i need to update my machine java before i run this jar. I can not run it before knowing this since it will get recorded in some logs and will update some server side files.
This is more of a Java question than a Maximo question, but no, it will not. You will get an "Unsupported major.minor version 52.0" if you do. This is not because of any features issue, this is simply because the bytecode is tagged as being from Java 8 and so earlier JREs will not run it.
Now this assumes you actually compiled the class files using Java 8, which probably only happened if you have custom code in there. If you are just using the out-of-the-box Maximo classes, those came pre-compiled (in I don't recall which version of Java) and so all you might have done was to bundle them into a jar, or more likely into the Maximo ear (since you don't run the businessobjects.jar). In that case, it doesn't matter what version of Java you used to created the jar/ear, it will run on any version of Java that is the same as or higher than whatever version IBM used to compile the code into classes.

Can't create JavaFX project within Netbeans on Linux

so I'm struggling with this issue quite a while now. I want to create a new JavaFX project within Netbeans, but I don't have the option to choose JavaFX from the list. Since I have the most recent java version, JavaFX should be included in the SDK right? I also looked up if I have the jfxrt.jar in the directory /usr/local/jdk1.8.0_111/jre/lib/ext and I do. So how comes that I can't create a regular JavaFX project? Am I missing out on something?
$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
Thank you in advance!
For those who are also having the same problem (can't find JAVAFX plugin(s) in the 'Installed' tab, see #Fabian comment answer):
Go to 'Settings' tab (in Tools -> Plugins)
Check both boxes 'Certified Plugins' and 'Netbeans Distribution'.
Go to 'Available Plugins' and press 'Check for Newest'.
You should see JAVAFX plugin(s).
Install them and restart your IDE.

cxf, jaxb on AIX/IBM Java - CollisionCheckStack issue

I had the following issue recently in my code. The environment is:
Java(TM) SE Runtime Environment (build pap6470sr1-20120330_01(SR1))
IBM J9 VM (build 2.6, JRE 1.7.0 AIX ppc64-64 20120322_106209 (JIT enabled, AOT enabled))
J9VM - R26_Java726_SR1_20120322_1720_B106209
Throwable occurred: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -14
at com.sun.xml.bind.v2.util.CollisionCheckStack.findDuplicate(CollisionCheckStack.java:133)
at com.sun.xml.bind.v2.util.CollisionCheckStack.push(CollisionCheckStack.java:71)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTypeRef(XmlSchemaGenerator.java:705)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$1900(XmlSchemaGenerator.java:429)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace$ElementWithType.writeTo(XmlSchemaGenerator.java:1273)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:583)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$600(XmlSchemaGenerator.java:429)
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:411)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.generateSchema(JAXBContextImpl.java:755)
at org.apache.cxf.jaxb.JAXBUtils.generateJaxbSchemas(JAXBUtils.java:760)
at org.apache.cxf.jaxb.JAXBDataBinding.generateJaxbSchemas(JAXBDataBinding.java:447)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:374)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:429)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:637)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:492)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:240)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:180)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:99)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:102)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:121)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:458)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:330)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:317)
at javax.xml.ws.Service.getPort(Service.java:130)
This code worked fine on Linux server with Oracle Java 1.7. It also worked on AIX with IBM Java 1.6. But it throws these exceptions when using IBM Java 1.7.
I did a research of com.sun.xml.bind.v2.util.CollisionCheckStack.findDuplicate(CollisionCheckStack.java:133)
And found some looking similar issues/answers, such as:
http://mydevtoolbox.blogspot.com/2013/07/jaxb-marshaller-no-threadsafe-error.html, which recommends “Create a Marshaller and Unmarshaller per request”
I don’t explicitly use Marshaller/Unmarshaller – it looks like CXF/JAXB issue on Java 1.7.
Any thoughts, insights, opinions are greatly appreciated.
Can you try using JAXB 2.2.4 based jars for IBM Java 1.7 and see if that solves the issue?
We had this issue after upgrading JAVA version from 1.6 to 1.8, to fix
you need to upgrade JAXB version from 1.x to 2.x.
Just had this problem
I was using Openj9 JDK and switched over to HotSpot. I used the IntelliJ JDK manager to download the JDK from OpenJDK and made my environmental variables point to the downloaded file structure (JAVA_HOME variable).
It solved the problem
This is not "real" answer, just a workaround suggestion.
The stack trace indicates you have a problem with schema generation. Maybe you could overcome this by providing an XML Schema explicitly using #XmlSchema.location. You'd have to generate and make this schema available manually. Not so cool, but if everything else fails...

Gradle fails to find JavaFX classes

I am on a Linux Mint machine where I installed the latest version of Java (HotSpot VM 1.7.0_45) and using Gradle 1.8.
I also have Groovy installed, version 1.8.6, but I think that does not matter as Gradle has its own groovy-all.jar.
My problem is that I could not compile my Groovy project using gradle because the JavaFX classes do not seem to be in the classpath. The errors are like this:
unable to resolve class javafx.scene.Node
# line 3, column 1.
import javafx.scene.Node
I finally fixed this by adding the following horrible hard-coded path into my dependencies:
compile files( "/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar" )
Is there a better way to add JavaFX to Gradle's compilation classpath so that it is visible to all my projects without me having to add this to each one of them??
I have tried everything I could imagine:
added the jfxrt.jar to the standard JRE (I confirmed gradle is using my standard java to run) ext folder, so that I now can compile java classes with javac and run them with java (I know that in this version of Java the JavaFX jar should be already in the JDK's classpath, but I still couldn't RUN, as opposed to compile, my Java app before doing this).
also added a soft link to the same jar in the groovy classpath, so that I can do something like shown below from the groovy shell and it works:
import javafx.application.Application as A ; println A
This also works in the Groovy Console.
It only does not work in Gradle!
Thanks for any help.
Use the JavaFX Gradle Plugin.
The JavaFX Gradle Plugin should be able to work out where the JavaFX runtime is located without you having to perform manual, environment specific configuration.
For further information on JavaFX classpath resolution (not Gradle related), see:
Compile code using JavaFX 2.0 (using command line).
Also note, if you are using Oracle Java 8 or newer, JavaFX classes are now on the default runtime classpath for an Oracle Java implementation.
Incidentally, the build system for the entire JavaFX system is based on Gradle, so there is definitely no incompatibility between JavaFX and Gradle.

"Undefined methods for the type "error after importing Netbeans project to Eclipse Pulsar

I imported a netbeans project into eclipse ( Pulsar for Mobile Developers.Version: Helios Service Release 1, Build id: 20100917-0705).
I have two errors multiple times -
The method nextInt() in the type Random is not applicable for the arguments (int)
The method equalsIgnoreCase(String) is undefined for the type String
The project works fine in netbeans but I am unable to debug it due to OutOfMemoryError and hence the switch to eclipse.
I have seen this but it did not solve my problem.
Any other hint to solve this problem ?
Salil
This is a bug on the WTK/eclipse integration https://bugs.eclipse.org/bugs/show_bug.cgi?id=315209
1.The method nextInt() in the type Random is not applicable for the
arguments (int)
2.The method equalsIgnoreCase(String) is undefined for the type String
The above two problems were solved by compiling the code using the latest Nokia S40 SDK.
The project works fine in netbeans but
I am unable to debug it due to
OutOfMemoryError and hence the switch
to eclipse.
Java Me 3.0 SDK comes installed with NetBeans but it is missing the Java_Platform_ME_SDK.exe found in C:\Java_ME_platform_SDK_3.0\toolbar\bin. I had to remove the default J2ME platform ( C:\Program Files (x86)\NetBeans 6.9.1\mobility\Java_ME_platform_SDK_3.0 ) and add the platform installed here - C:\Java_ME_platform_SDK_3.0.
Using Java_Platform_ME_SDK.exe I increased the emulator heap size to maximum and now I am able to debug my application.
Salil

Resources