Thought experiment: Gravitation effect of mass converted to energy Two masses M1 and M2 are separated by some distance.
M1 accelerates towards M2 and reciprocally.
Then because e=mc2, M1 converts totally into energy (which I believe would be photons) and vanishes.
Question: Does M2 stops accelerating towards M1 at the exact moment (whatever that means) that M1 disappears?
It is said that gravitation violates relativity because it "travels" at the speed of light, but maybe the information does not actually travel so fast. Maybe it takes 2 light-years for a body to register the presence of another body that is 2 light-years away, and then it is indefinitely attracted to it because it "knows" that it is there, and the speed of communication of the information that the mass of an object has changed cannot go faster than the speed of light.
Other question: Assuming the photons are in a hollow sphere (with negligible mass) and cannot escape, is M2 still attracted to that photon density?
Disclaimer: I am not a physicist, just curious, please be kind.
 A: $E=mc^2$ is a formula coming from the mathematical  constraints of special relativity.

M1 accelerates towards M2

Is an expression valid   in Newtonian mechanics.

M1 converts totally into energy (which I believe would be photons)

since you are talking about photons, they belong to quantum mechanics frame , where nothing spontaneously disappears without quantum mechanical interactions.
For the correct algebra, one must use the fourvectors of special relativity. Each mass will be described by a four vector $(E,p_x,p_y,p_z)$ where E is the energy of the mass and $p$ the momentum. The length of this vector is the invariant mass , and is the same in all inertial frames.

Thus, if by some unphysical way your $M_1$ decayed into photons, the sum of all those photon four vectors would alwayshave the invariant mass of $M_1$ , no matter how far away the photons get due to their velocity of light $c$. Almost immediately  $M_2$ will be within the $M_1$ mass and will not be sensitive to the attraction, as it will be within the expanding sphere of the photons.
Thought experiments need consistent frames .

Maybe it takes 2 light years for a body to register the presence of another body that is 2 light years away,

For interactions to happen ,yes it takes the time of the velocity of light to have an effect. When there is a change in the sun it takes 8 minutes to be seen on  the earth.
A: When the photons are contained in a massless perfectly reflecting sphere, then the two masses (one of which is now contained inside the sphere in the form of photons) will still be accelerating towards each other. If the spare is small enough the acceleration will be the same as for the two earlier masses.
If there is no sphere to contain the photons, the photons will spread, obviously. They spread with the speed of light (just as gravity). When the conversion of the mass to photons happens, the other mass will still move on as if the other mass were not transformed into photons yet. The photons travel toward each direction, including the direction where the other mass is. All the photons together will have the same gravitational influence on their surroundings as the mass they came from. They form an expanding sphere. When the photons, traveling behind the gravity influence (with the same speed as the gravity influence) of the mass they came from, reach the other mass (say they can all pass the other mass) the gravitational influence on the other mass will change. when the ball of photons has reached an enormous size they will not influence the other mass anymore.
So what will the other mass see? The other mass sees the mass were the photons came from until the photons reach this mass. Because the speed of gravity equals the speed of light, the moment the other mass sees the photons is also the moment from which the gravity on the other mass starts to diminish.
S
