The Bible says a lot of things that are hard to understand about joy.
James 1 implies that we should objectively understand trials as joy. This is because we know that trials result in our sanctification. When we know the final product we can have joy. Joy is not separated from circumstances, but Christians have the benefit of know the final result and can focus on different circumstances; namely Jesus saving people through his work on the cross.